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

    return ();
}

1;