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.
|
|
|
package MWTemplate;
|
|
|
|
|
|
|
|
use v5.30;
|
|
|
|
|
|
|
|
use feature "signatures";
|
|
|
|
no warnings "experimental::signatures";
|
|
|
|
|
|
|
|
my $DEBUG = 1;
|
|
|
|
|
|
|
|
sub Parse($input, $template_name)
|
|
|
|
{
|
|
|
|
# say STDERR "Looking for $template_name in:";
|
|
|
|
# say STDERR $input;
|
|
|
|
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;
|