Last active
December 19, 2015 18:59
-
-
Save ian-kent/6002917 to your computer and use it in GitHub Desktop.
Text xslate undefined function with virtual templates
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( | |
path => { | |
'test.tx' => qq{ | |
: capture(-> { | |
Rendering <: count() :> | |
: }) | |
: render() | |
} | |
}, | |
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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment