summaryrefslogtreecommitdiffstats
path: root/lib/Text/Handlebars/Compiler.pm
blob: 5f112fcef72b717116c458e8082947053419dd8f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package Text::Handlebars::Compiler;
use Any::Moose;

extends 'Text::Xslate::Compiler';

has '+syntax' => (
    default => 'Handlebars',
);

sub _generate_block {
    my $self = shift;
    my ($node) = @_;

    my @compiled = map { $self->compile_ast($_) } @{ $node->second };

    unshift @compiled, $self->_localize_vars($node->first)
        if $node->first;

    return @compiled;
}

if (0) {
    our $_recursing;
    around compile_ast => sub {
        my $orig = shift;
        my $self = shift;

        my @ast = do {
            local $_recursing = 1;
            $self->$orig(@_);
        };
        use Data::Dump; ddx(\@ast) unless $_recursing;
        return @ast;
    };
}

__PACKAGE__->meta->make_immutable;
no Any::Moose;

1;