DESCRIPTION

Mojo::Template is a minimalistic and very Perl-ish template engine, designed specifically for all those small tasks that come up during big projects. Like preprocessing a configuration file, generating text from heredocs and stuff like that.

escape_mark

Character indicating the start of an escaped expression, defaults to =.

<%== $foo %>

expression_mark

my $mark = $mt->expression_mark;
$mt = $mt->expression_mark('=');

Character indicating the start of an expression, defaults to =.

<%= $foo %>

line_start

my $start = $mt->line_start;
$mt = $mt->line_start('%');

Character indicating the start of a code line, defaults to %.

% $foo = 23;

name

my $name = $mt->name;
$mt = $mt->name('foo.mt');

Name of template currently being processed, defaults to template. Note that this value should not contain quotes or newline characters, or error messages might end up being wrong.

namespace

my $namespace = $mt->namespace;
$mt = $mt->namespace('main');

Namespace used to compile templates, defaults to Mojo::Template::SandBox. Note that namespaces should only be shared very carefully between templates, since functions and global variables will not be cleared automatically.

prepend

my $code = $mt->prepend;
$mt = $mt->prepend('my $self = shift;');

Prepend Perl code to compiled template. Note that this code should not contain newline characters, or line numbers in error messages might end up being wrong.

replace_mark

my $mark = $mt->replace_mark;
$mt = $mt->replace_mark('%');

Character used for escaping the start of a tag or line, defaults to %.

<%% my $foo = 23; %>

tag_start

my $start = $mt->tag_start;
$mt = $mt->tag_start('<%');

Characters indicating the start of a tag, defaults to <%.

<% $foo = 23; %>

tag_end

my $end = $mt->tag_end;
$mt = $mt->tag_end('%>');

Characters indicating the end of a tag, defaults to %>.

<%= $foo %>

template

my $template = $mt->template;
$mt = $mt->template($template);

Raw unparsed template.

tree

my $tree = $mt->tree;
$mt = $mt->tree([['text', 'foo']]);

Template in parsed form. Note that this structure should only be used very carefully since it is very dynamic.