I am creating a HTML template that I want populate only some of the variables (TMPL_VARs) in it, then output it to a file that I will call again at a later date to populate the rest of the variables. So basically I want to escape some of the TMPL variables so they can be populated on the second pass.
The only solutions i can think of is to set the second pass of vars to <TMPL_VAR NAME=test> and either:
1. output the first pass to a file, then call the new template with the filter param which converts all /<TMPL/<TMPL/g. I don't like this way as it has to run a regexp subst on each template as it's loaded, and the second pass is the one that is used more often, the first pass is just to create the structure for the second pass.
2. store template output into a scalar and to a regexp subst on the scalar before printint that to the file.
my $templateRef = $template->output;
$templateRef =~ s/<TMPL_/<TMPL_/g;
print TEMP $templateRef;
As I am writing this I think I'm going to go with solution 2 as it outputs the file and doesn't require any filter on loading the second template.
Any feedback on this would be great though, otherwise maybe this might help someone else who is looking for a similar solution.