diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-10-08 13:33:45 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-10-08 13:33:45 -0500 |
commit | 6d3b76546c92f15aadc2a9c4b7568411e49ccfbe (patch) | |
tree | 99d12c1e4c9d73765fa9bc09320f896cdae50ca4 /lib/Text/Handlebars.pm | |
parent | 7f47485c049416b1c4386d21531f1e50ae3acd79 (diff) | |
download | text-handlebars-6d3b76546c92f15aadc2a9c4b7568411e49ccfbe.tar.gz text-handlebars-6d3b76546c92f15aadc2a9c4b7568411e49ccfbe.zip |
implement hash parameters for block helpers
Diffstat (limited to 'lib/Text/Handlebars.pm')
-rw-r--r-- | lib/Text/Handlebars.pm | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Text/Handlebars.pm b/lib/Text/Handlebars.pm index 4a66fe6..f8d1692 100644 --- a/lib/Text/Handlebars.pm +++ b/lib/Text/Handlebars.pm @@ -55,6 +55,10 @@ sub default_functions { my ($length) = @_; return [(undef) x $length]; }, + '(make_hash)' => sub { + my (%hash) = @_; + return \%hash; + }, '(is_code)' => sub { my ($val) = @_; return ref($val) && ref($val) eq 'CODE'; @@ -122,7 +126,7 @@ sub _register_builtin_methods { return 0; }; $funcs->{'(make_block_helper)'} = sub { - my ($code, $raw_text, $else_raw_text) = @_; + my ($code, $raw_text, $else_raw_text, $hash) = @_; my $options = {}; $options->{fn} = sub { @@ -133,6 +137,7 @@ sub _register_builtin_methods { my ($new_vars) = @_; return $weakself->render_string($else_raw_text, $new_vars); }; + $options->{hash} = $hash; return sub { $code->(@_, $options); }; }; |