diff options
-rw-r--r-- | lib/Text/Handlebars.pm | 1 | ||||
-rw-r--r-- | lib/Text/Xslate/Syntax/Handlebars.pm | 21 | ||||
-rw-r--r-- | t/block-helpers.t | 3 |
3 files changed, 5 insertions, 20 deletions
diff --git a/lib/Text/Handlebars.pm b/lib/Text/Handlebars.pm index bbc53a9..7316ce8 100644 --- a/lib/Text/Handlebars.pm +++ b/lib/Text/Handlebars.pm @@ -46,6 +46,7 @@ sub default_functions { weaken(my $vars_copy = $vars); return { + '@index' => $i, %$vars, %$value, '..' => $vars_copy, diff --git a/lib/Text/Xslate/Syntax/Handlebars.pm b/lib/Text/Xslate/Syntax/Handlebars.pm index c08cee9..940d30d 100644 --- a/lib/Text/Xslate/Syntax/Handlebars.pm +++ b/lib/Text/Xslate/Syntax/Handlebars.pm @@ -20,7 +20,7 @@ my $OPERATOR_TOKEN = sprintf( join('|', map{ quotemeta } qw(..)) ); -sub _build_identity_pattern { qr/[A-Za-z_][A-Za-z0-9_?-]*/ } +sub _build_identity_pattern { qr/\@?[A-Za-z_][A-Za-z0-9_?-]*/ } sub _build_comment_pattern { qr/\![^;]*/ } sub _build_line_start { undef } @@ -575,25 +575,6 @@ sub std_partial { ); } -sub nud_iterator { - my $self = shift; - my ($symbol) = @_; - - my $token = $self->token; - if ($token->arity ne 'variable') { - $self->_unexpected('iterator variable', $token); - } - - $self->advance; - - if ($token->id eq 'index') { - return $self->iterator_index; - } - else { - $self->_error("Unknown iterator variable " . $token->id); - } -} - sub undefined_name { my $self = shift; my ($name) = @_; diff --git a/t/block-helpers.t b/t/block-helpers.t index ac6f54f..5ca009a 100644 --- a/t/block-helpers.t +++ b/t/block-helpers.t @@ -331,6 +331,9 @@ RENDERED "helper arguments" ); +# XXX this is almost certainly not what the api should be like, but i don't +# understand the purpose for this feature well enough to come up with anything +# more reasonable. feedback welcome! render_ok( { function => { |