diff options
Diffstat (limited to 'lib/Text/Handlebars.pm')
-rw-r--r-- | lib/Text/Handlebars.pm | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/Text/Handlebars.pm b/lib/Text/Handlebars.pm index 471d2f0..11de467 100644 --- a/lib/Text/Handlebars.pm +++ b/lib/Text/Handlebars.pm @@ -64,7 +64,6 @@ sub options { my $options = $class->SUPER::options(@_); $options->{compiler} = 'Text::Handlebars::Compiler'; - $options->{helpers} = {}; return $options; } @@ -88,19 +87,16 @@ sub _register_builtin_methods { return 1 if try { $weakself->find_file($filename); 1 }; return 0; }; + $funcs->{'(run_block_helper)'} = sub { + my ($code, $raw_text, $vars, @args) = @_; - for my $helper (keys %{ $self->{helpers} }) { - my $code = $self->{helpers}{$helper}; - $funcs->{$helper} = sub { - my ($raw_text, $vars, @args) = @_; - my $recurse = sub { - my ($new_vars) = @_; - return $weakself->render_string($raw_text, $new_vars); - }; - - return $code->($vars, @args, { fn => $recurse }); - } - } + my $recurse = sub { + my ($new_vars) = @_; + return $weakself->render_string($raw_text, $new_vars); + }; + + return $code->($vars, @args, { fn => $recurse }); + }; } 1; |