DreamT has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
Usually, when using a TT file in another TT file, the syntax could look as follows:
[% PROCESS 'my_included_file.tt' %]

But, let's say that the included file isn't a physical file, but is stored in a variable:
[% SET template = fetch_template('my_parameter') %]

Is it possible to PROCESS that variable and get the same result as if this was a physical file?
[% PROCESS template???? %]

Replies are listed 'Best First'.
Re: Including template in template from other source than .tt file
by Your Mother (Archbishop) on Apr 18, 2018 at 16:23 UTC
Re: Including template in template from other source than .tt file
by poj (Abbot) on Apr 18, 2018 at 17:04 UTC

    Do you mean the template text is stored in a variable, not a filename ? Something like this using BLOCKS

    #!/usr/bin/perl use strict; use Template; my $tt = Template->new({ BLOCKS => { tvar => 'Text is [% text %]', }, }); my $vars = { text => 'Some text' }; $tt->process(\*DATA, $vars); __DATA__ [% INCLUDE tvar %]
    poj
Re: Including template in template from other source than .tt file
by hippo (Archbishop) on Apr 18, 2018 at 15:25 UTC

    I think you want the eval filter by the sounds of it.

Re: Including template in template from other source than .tt file (Template::Provider)
by beech (Parson) on Apr 19, 2018 at 22:24 UTC