Jinja2-TT2
view release on metacpan or search on metacpan
### Loops
```jinja2
{% for item in items %} â [% FOREACH item IN items %]
{{ loop.index }} â [% loop.count %]
{{ loop.first }} â [% loop.first %]
{{ loop.last }} â [% loop.last %]
{% endfor %} â [% END %]
```
### Blocks and Macros
```jinja2
{% block content %} â [% BLOCK content %]
{% endblock %} â [% END %]
{% macro btn(text) %} â [% MACRO btn(text) BLOCK %]
{% endmacro %} â [% END %]
```
### Comments
bin/jinja2tt2 view on Meta::CPAN
=item * Filters (most common ones)
=item * for loops (including else clause)
=item * if/elif/else conditionals
=item * Blocks and inheritance (partial)
=item * Includes
=item * Macros
=item * Comments
=item * Whitespace control (-% tags)
=back
=head1 LIMITATIONS
=over 4
t/03-emitter.t view on Meta::CPAN
};
subtest 'Set statement' => sub {
is(
transpile('{% set x = 42 %}'),
'[% x = 42 %]',
'Set variable'
);
};
subtest 'Macro' => sub {
my $result = transpile('{% macro greet(name) %}Hello {{ name }}{% endmacro %}');
like($result, qr/MACRO greet\(name\) BLOCK/, 'Macro definition');
like($result, qr/\[% name %\]/, 'Macro body');
};
subtest 'Whitespace control' => sub {
like(transpile('{{- name -}}'), qr/\[%-.*-%\]/, 'Whitespace control markers');
};
subtest 'String concatenation' => sub {
like(transpile('{{ a ~ b }}'), qr/\(a _ b\)/, 'Tilde becomes underscore');
};
( run in 1.487 second using v1.01-cache-2.11-cpan-483215c6ad5 )