diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-10-18 13:50:24 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-01-02 13:56:20 -0600 |
commit | 174ac6de8d5e349b32480ffd8e0f0c3feae87a62 (patch) | |
tree | 750bda03143ced50e3d976a3ddfa0fc2771ac230 /lib/Text/Handlebars.pm | |
parent | 01c2301937d6c0029408a40fa5e4a5c868516e4c (diff) | |
download | text-handlebars-174ac6de8d5e349b32480ffd8e0f0c3feae87a62.tar.gz text-handlebars-174ac6de8d5e349b32480ffd8e0f0c3feae87a62.zip |
reimplement new_vars_for in terms of merge_hash
Diffstat (limited to 'lib/Text/Handlebars.pm')
-rw-r--r-- | lib/Text/Handlebars.pm | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/lib/Text/Handlebars.pm b/lib/Text/Handlebars.pm index 154a78b..787ac22 100644 --- a/lib/Text/Handlebars.pm +++ b/lib/Text/Handlebars.pm @@ -124,26 +124,9 @@ sub default_functions { return { %{ $class->SUPER::default_functions(@_) }, %{ $class->default_helpers }, - '(new_vars_for)' => sub { - my ($vars, $value, $i) = @_; - - if (ref($value) eq 'ARRAY') { - $value = ref($value->[$i]) eq 'HASH' - ? { '.' => $value->[$i], %{ $value->[$i] } } - : { '.' => $value->[$i] }; - } - - if (ref($value) eq 'HASH') { - return { - '@index' => $i, - %$vars, - %$value, - '..' => $vars, - }; - } - else { - return $vars; - } + '(merge_hash)' => sub { + my ($left, $right) = @_; + return { %$left, %$right }; }, }; } |