From 174ac6de8d5e349b32480ffd8e0f0c3feae87a62 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 18 Oct 2012 13:50:24 -0500 Subject: reimplement new_vars_for in terms of merge_hash --- lib/Text/Handlebars.pm | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'lib/Text/Handlebars.pm') 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 }; }, }; } -- cgit v1.2.3-54-g00ecf