The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Text::Xslate::Syntax::TTerse - An alternative syntax like Template-Toolkit 2

SYNOPSIS

    use Text::Xslate;
    my $tx = Text::Xslate->new(
        syntax => 'TTerse',
    );

    print $tx->render_string(
        'Hello, [% dialect %] world!',
        { dialect => 'TTerse' }
    );

DESCRIPTION

TTerse is a subset of the Template-Toolkit 2 syntax, using [% ... %] tags.

SYNTAX

Note that lower-cased keywords are also allowed.

Variable access

Scalar access:

    [%  var %]
    [% $var %]

Field access:

    [% var.0 %]
    [% var.field %]
    [% var.accessor %]

Variables may be HASH references, ARRAY references, or objects.

If $var is an object instance, you can call its methods.

    [% $var.method() %]
    [% $var.method(1, 2, 3) %]

Expressions

Almost the same as Text::Xslate::Syntax::Kolon.

Loops

    [% FOREACH item IN arrayref %]
        * [% item %]
    [% END %]

Conditional statements

    [% IF expression %]
        This is true
    [% ELSE %]
        Tis is false
    [% END %]

    [% IF expression %]
        Case 1
    [% ELSIF expression %]
        Case 2
    [% ELSE %]
        Case 3
    [% END %]

Functions and filters

    [% var | f %]
    [% f(var)  %]

Template inclusion

    [% INCLUDE "file.tt" %]
    [% INCLUDE $var %]

Template cascading

Not supported.

Macro blocks

Not supported.

SEE ALSO

Text::Xslate

Template::Toolkit

Template::Tiny