NAME

Jinja2::TT2 - Transpile Jinja2 templates to Template Toolkit (TT2)

SYNOPSIS

use Jinja2::TT2;

my $transpiler = Jinja2::TT2->new();
my $tt2_output = $transpiler->transpile($jinja2_template);

# Or from a file
my $tt2_output = $transpiler->transpile_file('template.j2');

DESCRIPTION

This module converts Jinja2 template syntax to Template Toolkit 2 (TT2) syntax. It performs a mechanical translation, mapping Jinja2 constructs to their TT2 equivalents.

METHODS

new(%options)

Create a new transpiler instance.

Options: debug => 1 # Print tokenizer and parser debug output

transpile($template_string)

Transpile a Jinja2 template string to TT2.

transpile_file($filename)

Read a file and transpile its contents.

SUPPORTED CONSTRUCTS

  • Variables: {{ foo.bar }}[% foo.bar %]

  • Filters: {{ name|upper }}[% name | upper %]

  • Conditionals: {% if %}[% IF %]

  • Loops: {% for x in items %}[% FOREACH x IN items %]

  • Blocks: {% block name %}[% BLOCK name %]

  • Includes: {% include 'file' %}[% INCLUDE file %]

  • Comments: {# comment #}[%# comment %]

AUTHOR

Generated with Claude Code

LICENSE

This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 105:

Non-ASCII character seen before =encoding in '→'. Assuming UTF-8