Skip to content

Instantly share code, notes, and snippets.

@ian-kent
Created July 15, 2013 18:39
Show Gist options
  • Save ian-kent/6002292 to your computer and use it in GitHub Desktop.
Save ian-kent/6002292 to your computer and use it in GitHub Desktop.
Xslate undefined function error with blessed object capturing macro
package main;
use Data::Dumper;
use Text::Xslate;
my $count = 0;
my $macro = undef;
my $xslate = Text::Xslate->new(
cache => 1,
function => {
count => sub {
++$count;
},
capture => sub {
$macro = bless { macro => shift }, 'test';
undef;
},
render => sub {
$macro->{macro}->();
}
}
);
# works with cache 0/1/2
print $xslate->render('test.tx');
# works with cache 0, undefined function with cache 1/2
print $xslate->render('test.tx');
# works with cache 0, also undefined function with cache 1/2
print $xslate->render('test.tx');
: capture(-> {
Rendering <: count() :>
: })
: render()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment