You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Multiple function/filter parameters work in Template Toolkit e.g.:
[% "The cat sat on the mat" | replace('\s+', '_') %]
- but don't appear to be supported in Text::Xslate.
Test case (I know replace is available elsewhere: it's just an example):
#!/usr/bin/env perluse strict;
use warnings;
use Test::More tests=> 4;
use Text::Xslate;
use constant {
FILTER=>'[% name | replace("ohn", "ane") %]',
FUNCTION=>'[% replace(name, "ane", "ohn") %]',
};
subreplace($;$$) {
my$string = shift;
my$params = is(scalar(@_), 2);
if ($params) {
my ($search, $replace) = @_;
$string =~ s{$search}{$replace};
}
return$string;
}
my$template = Text::Xslate->new(syntax=>'TTerse', function=> { replace=> \&replace });
my$rendered_filter = $template->render_string(FILTER, { name=>'John Doe' });
my$rendered_function = $template->render_string(FUNCTION, { name=>'Jane Doe' });
is $rendered_filter, 'Jane Doe';
is $rendered_function, 'John Doe';
The text was updated successfully, but these errors were encountered:
chocolateboy
changed the title
Wishlist (TTerse): add support for function/filter parameters
Wishlist (TTerse): add support for multiple function/filter parameters
Apr 26, 2014
Perl: v5.16.0
Text::Xslate: 3.2.3
Multiple function/filter parameters work in Template Toolkit e.g.:
- but don't appear to be supported in Text::Xslate.
Test case (I know
replace
is available elsewhere: it's just an example):The text was updated successfully, but these errors were encountered: