Created
July 15, 2013 18:32
-
-
Save ian-kent/6002248 to your computer and use it in GitHub Desktop.
Xslate segfault when using nested blessed objects
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 helper; | |
sub new { | |
my ($package, %args) = @_; | |
return bless { | |
%args | |
}, 'helper'; | |
} | |
sub test { | |
my $self = shift; | |
$self->{block} = bless { macro => pop }, 'test'; | |
return $self; | |
} | |
sub render { | |
shift->{block}->{macro}->(); | |
} | |
package main; | |
use Data::Dumper; | |
use Text::Xslate; | |
my $count = 0; | |
my $xslate = Text::Xslate->new( | |
cache => 1, | |
function => { | |
count => sub { | |
++$count; | |
} | |
} | |
); | |
my $params = { | |
c => helper->new | |
}; | |
# works with cache 0/1/2 | |
print $xslate->render('test.tx', $params ); | |
# works with cache 0, undefined function with cache 1/2 | |
print $xslate->render('test.tx', $params ); | |
# works with cache 0, segfault for cache 1/2 | |
print $xslate->render('test.tx', $params ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment