diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-10-14 13:20:05 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-10-14 14:38:14 -0500 |
commit | 5170de4d15d7ff92f3c2a1897caa91928a8855ed (patch) | |
tree | 9cbb16e35da3a224979932c51ec0b97b43dfeb82 /lib/Text | |
parent | 91eb6cf8098bb675220e9e63111febf69f6cddfd (diff) | |
download | text-handlebars-5170de4d15d7ff92f3c2a1897caa91928a8855ed.tar.gz text-handlebars-5170de4d15d7ff92f3c2a1897caa91928a8855ed.zip |
make_array doesn't need to be a function
Diffstat (limited to 'lib/Text')
-rw-r--r-- | lib/Text/Handlebars.pm | 4 | ||||
-rw-r--r-- | lib/Text/Handlebars/Compiler.pm | 14 |
2 files changed, 12 insertions, 6 deletions
diff --git a/lib/Text/Handlebars.pm b/lib/Text/Handlebars.pm index 29123be..4d0a137 100644 --- a/lib/Text/Handlebars.pm +++ b/lib/Text/Handlebars.pm @@ -133,10 +133,6 @@ sub default_functions { return !$val; } }, - '(make_array)' => sub { - my ($length) = @_; - return [(undef) x $length]; - }, '(make_hash)' => sub { my (%hash) = @_; return \%hash; diff --git a/lib/Text/Handlebars/Compiler.pm b/lib/Text/Handlebars/Compiler.pm index 77c4726..d713fc1 100644 --- a/lib/Text/Handlebars/Compiler.pm +++ b/lib/Text/Handlebars/Compiler.pm @@ -127,11 +127,11 @@ sub _generate_block { my $iterations = $self->make_ternary( $self->call($node, '(is_falsy)', $name->clone), - $self->call($node, '(make_array)', $self->parser->literal(1)), + $self->make_array($self->parser->literal(1)), $self->make_ternary( $self->is_array_ref($name->clone), $name->clone, - $self->call($node, '(make_array)', $self->parser->literal(1)), + $self->make_array($self->parser->literal(1)), ), ); @@ -277,6 +277,16 @@ sub is_array_ref { ); } +sub make_array { + my $self = shift; + my (@contents) = @_; + + return $self->parser->symbol('[')->clone( + arity => 'composer', + first => \@contents, + ); +} + __PACKAGE__->meta->make_immutable; no Any::Moose; |