aboutsummaryrefslogtreecommitdiffstats
path: root/lib/LXRng/Lang/Generic.pm
blob: 29443f49f7d09e880bd78603f50f21bd915371bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;