perl capture of "rendered" templates


Randall Diffenderfer
 

in the PERL directive area, i'd like to be able to PROCESS a template and capture its output, but *not* have that go to the output buffer.  i want to fiddle with that output, and then  'print' it to the buffer.

i thought that "my $stuff = $context->process('template.tt') " would work, with the variables being "inherited" from the context, i.e. those that were presented to the template containing the PERL directive, $stuff being the scalar of what would have gone to the output buffer.

this doesn't seem to what i have in mind.  what gotchas surround this idea with respect to providing variable to the template i want to process in the PERL directive?


"Dami Laurent (PJ)"
 

Hi,

The proces(..) method can take an argument in 3rd position that specifies the output destination (filename, filehandle, variable in memory).

 

De : template-toolkit@groups.io <template-toolkit@groups.io> De la part de Randall Diffenderfer via groups.io
Envoyé : lundi 27 juin 2022 17:21
À : template-toolkit@groups.io
Objet : [template-toolkit] perl capture of "rendered" templates

 

in the PERL directive area, i'd like to be able to PROCESS a template and capture its output, but *not* have that go to the output buffer.  i want to fiddle with that output, and then  'print' it to the buffer.

i thought that "my $stuff = $context->process('template.tt') " would work, with the variables being "inherited" from the context, i.e. those that were presented to the template containing the PERL directive, $stuff being the scalar of what would have gone to the output buffer.

this doesn't seem to what i have in mind.  what gotchas surround this idea with respect to providing variable to the template i want to process in the PERL directive?