Created
July 15, 2013 18:39
-
-
Save ian-kent/6002292 to your computer and use it in GitHub Desktop.
Xslate undefined function error with blessed object capturing macro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: capture(-> { | |
Rendering <: count() :> | |
: }) | |
: render() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment