You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
wiki-map/MWTemplate.pm

25 lines
535 B

package MWTemplate;
use v5.30;
use feature "signatures";
no warnings "experimental::signatures";
my $DEBUG = 1;
sub Parse($input, $template_name)
{
my ($contents) = $input =~ /\{\{ \s* $template_name \s* \| (.*?) \}\}/sx;
return 0 unless $contents;
my @params = split /\|/, $contents;
my @positional_params;
my %named_params;
foreach (@params)
{
if(/(.*?)=(.*)/) { $named_params{$1} = $2 }
else { push @positional_params, $_ }
}
return {positional_params => \@positional_params, named_params => \%named_params};
}
1;