Search code examples
perltemplate-toolkit

How to just compile templates in Template::Toolkit?


What's the best way to 'compile only' (so to their Perl compiled version) templates for template toolkit.

So far I've called ->process on them, but as it really execute the templates, that's far from ideal.

Ideally I'd like to 'just compile' templates to their Perl version without evaluating them.


Solution

  • As documented on CPAN, it is possible like so:

    my $tt = Template->new;
    my $templateFile = "something.html";
    my $compiledTemplate = $tt->template($templateFile);