logo       
Google Custom Search
    AddThis Social Bookmark Button

Processing a template stored in a variable.: msg#00046

Subject: Processing a template stored in a variable.
Hello,

I am trying to process a template that is stored in a TT variable. However,
I can't get it to work. Is it possible?  I have included a little program to
demonstrate what I am trying to do:



#!/usr/bin/perl -w

use strict;
use Template;

my $t = new Template;
my $embeddedTemplate = q(
        [% FOREACH i = [ 1 .. 10 ] %]
                i = [% i %]
        [% END %]
);

# Ideally, $mainTemplate would process the template that is stored in 
# embTemplate, but, alas, it does not. :-(

my $mainTemplate = '[% PROCESS embTemplate %]'; 

$t->process(\$mainTemplate, { embTemplate => $embeddedTemplate, }) 
        or die $t->error();



As is, this program results in this error:

file error - embTemplate: not found

I understand that it is looking for a template called embTemplate, so I
changed $mainTemplate to '[% PROCESS $embTemplate %]'. This, as you probably
already know, didn't work either.

Any suggestions would be much appreciated.

Regards,
 
Travis Spencer
Portland, OR USA
 
   __o
 _-\<,
(_)/(_)____



Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>