summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-10-05 13:14:14 -0500
committerJesse Luehrs <doy@tozt.net>2012-10-05 13:16:21 -0500
commitab64f8c31f63d5be9fb109fb062bb562064553b9 (patch)
tree5fbb9f49a5d2cdcba19e7d18fb20fe1c51ba8a90
parentdaa216440c90d3b11441ebe24b587ad721605041 (diff)
downloadtext-handlebars-ab64f8c31f63d5be9fb109fb062bb562064553b9.tar.gz
text-handlebars-ab64f8c31f63d5be9fb109fb062bb562064553b9.zip
actually, @foo just seems to be another kind of variable?
really can't tell what the difference is between passing data in as normal template variables and passing them in as "template data" probably just won't support template data until someone can explain this better, because the handlebars test suite isn't very clear on the subject
-rw-r--r--lib/Text/Handlebars.pm1
-rw-r--r--lib/Text/Xslate/Syntax/Handlebars.pm21
-rw-r--r--t/block-helpers.t3
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 => {