summaryrefslogtreecommitdiffstats
path: root/lib/Text/Handlebars.pm
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-10-04 17:39:32 -0500
committerJesse Luehrs <doy@tozt.net>2012-10-04 17:39:32 -0500
commit813512b43e411bb8657ecc3f9715943afff07b37 (patch)
tree897a70885293d4a7772e720ea88618f25113316e /lib/Text/Handlebars.pm
parentcfbd9cd78c34ed3f9e123b8a7988d778bc389ef1 (diff)
downloadtext-handlebars-813512b43e411bb8657ecc3f9715943afff07b37.tar.gz
text-handlebars-813512b43e411bb8657ecc3f9715943afff07b37.zip
refactor this so that helpers are just normal functions
Diffstat (limited to 'lib/Text/Handlebars.pm')
-rw-r--r--lib/Text/Handlebars.pm22
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;