To use this engine, you may configure manual Dancer2 via config.yaml
:
template: "TTLogReport"
Or you may also change the rendering engine on a per-route basis by
setting it manually with set
:
set template => 'TTLogReport';
Application:
# In your daemon startup my $pot = Log::Report::Translator::POT->new(lexicon => $poddir); my $domain = (engine 'template')->addTextdomain(name => $mydomain); $domain->configure(translator => $pot); # Use it: get '/' => sub { template index => { title => 'my webpage', # The actual language is stored in the user session. translate_to => 'nl_NL.utf-8', }; };
This template engine allows you to use manual Template::Toolkit in manual Dancer2, including the translation extensions offered by Log::Report::Template.
Most configuration variables are available when creating a new instance of a manual Template::Toolkit object can be declared in your config.yml file. For example:
template: TTLogReport engines: template: TTLogReport: start_tag: '<%' end_tag: '%>'
(Note: start_tag
and end_tag
are regexes. If you want to use PHP-style
tags, you will need to list them as < <\?
> and < \?
>>.)
See manual Template::Manual::Config for the configuration variables.
In addition to the standard configuration variables, the option show_private_variables
is also available. Template::Toolkit, by default, does not render private variables
(the ones starting with an underscore). If in your project it gets easier to disable
this feature than changing variable names, add this option to your configuration.
show_private_variables: true
Warning: Given the way Template::Toolkit implements this option, different Dancer2 applications running within the same interpreter will share this option!
Module manual Dancer2::Template::TemplateToolkit describes how to extend the Template
by wrapping the _build_engine
method. The instantiation trick is insufficient
for a bit more complex modules, like our Log::Report translation feature. You may
be able to extend this module with your own templater, however.
# in config.yml engines: template: TTLogReport: start_tag: '<%' end_tag: '%>' templater: Log::Report::Template # default
=encoding utf-8