diff options
Diffstat (limited to 'lib/LXRng/Lang/Generic.pm')
-rw-r--r-- | lib/LXRng/Lang/Generic.pm | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/LXRng/Lang/Generic.pm b/lib/LXRng/Lang/Generic.pm new file mode 100644 index 0000000..29443f4 --- /dev/null +++ b/lib/LXRng/Lang/Generic.pm @@ -0,0 +1,22 @@ +package LXRng::Lang::Generic; + +use strict; + +sub expand_include { + my ($self, $context, $node, $include) = @_; + + return () unless $context->config->{'include_maps'}; + + my $file = $node->name(); + foreach my $map (@{$context->config->{'include_maps'}}) { + my @key = $file =~ /($$map[0])/ or next; + my @val = $include =~ /($$map[1])/ or next; + shift(@key); + shift(@val); + my @paths = $$map[2]->(@key, @val); + + return map { /([^\/].*)/ ? $1 : $_ } @paths; + } +} + +1; |