Skip to content

Instantly share code, notes, and snippets.

@ian-kent
Created July 15, 2013 18:33
Show Gist options
  • Save ian-kent/6002258 to your computer and use it in GitHub Desktop.
Save ian-kent/6002258 to your computer and use it in GitHub Desktop.
No segfault in xslate when using a single level of blessed hash
package helper;
sub new {
my ($package, %args) = @_;
return bless {
%args
}, 'helper';
}
sub test {
my $self = shift;
$self->{block} = pop;
return $self;
}
sub render {
shift->{block}->();
}
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