From 703ac3ef783a86eac77af2c402c6600c33e6a71c Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 8 Oct 2012 14:15:23 -0500 Subject: move more bits into the compiler --- lib/Text/Handlebars/Compiler.pm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'lib/Text/Handlebars/Compiler.pm') diff --git a/lib/Text/Handlebars/Compiler.pm b/lib/Text/Handlebars/Compiler.pm index 54f760d..5ffe882 100644 --- a/lib/Text/Handlebars/Compiler.pm +++ b/lib/Text/Handlebars/Compiler.pm @@ -105,6 +105,8 @@ sub _generate_call { my $hash = $parser->call($make_hash, @hash); + unshift @args, $parser->vars; + if ($node->first->arity eq 'call' && $node->first->first->id eq '(make_block_helper)') { push @{ $node->first->second }, $hash; $node->second(\@args); @@ -117,6 +119,34 @@ sub _generate_call { return $self->SUPER::_generate_call($node); } +sub _generate_partial { + my $self = shift; + my ($node) = @_; + + my $parser = $self->parser; + + my $find_file = $parser->symbol('(name)')->clone( + arity => 'name', + id => '(find_file)', + line => $node->line, + ); + + return $self->compile_ast( + $parser->make_ternary( + $parser->call($find_file, $node->first->clone), + $node->clone( + arity => 'include', + id => 'include', + first => $node->first, + ), + $node->clone( + arity => 'literal', + id => '', + ), + ), + ); +} + __PACKAGE__->meta->make_immutable; no Any::Moose; -- cgit v1.2.3-54-g00ecf