Emmanuel Quevillon writes:

> Harald Joerg wrote:
>> [...]
>> There's nothing wrong with the templates you provided.  Let me demonstrate
>> by converting it to a fully functional program:
>> ----------------------------------------------------------------------
>> #!perl -w
>>
>> use Template;
>>
>> my $t = Template->new();
>>
>> $t->process(\*DATA) || die $t->error(), "\n";
>>
>> __DATA__
>> [% BLOCK B %]
>> [% FOREACH i IN item %]
>>
>> [% i.name %]
>>
>> [% END %]
>> [% END %]
>> <html>
>> [% bar = [ {items => [ {name=>'Emmanuel'},{name=>'Harald'} ] } ,
>>            {items => [ {name=>'Quevillon'},{name=>'Joerg'} ] } ,
>>          ]
>> %]
>> ...
>> [% FOREACH foo IN bar %]
>> ..
>> [% PROCESS B item = foo.items %]
>> ...
>> [% END %]
>> </html>
>> ----------------------------------------------------------------------
>>
>> If you get no output at all, then you should inspect the error from
>> the process() call to TT, like in my example code.  With complicated
>> data structures like that it is too easy to miss some bracket...
>
> Hi Harald,
>
> Sorry for the late reply and thank you for your example, I
> ran it without errors.
> Maybe I forgot to mentioned something in my first email, the
> thing is that templates A and B are separated template file.
> I'd like to PROCESS template B inside template A. Is it then
> possible without declaring a BLOCK inside template A?

Whether the templates are in separate files or in blocks in one file
doesn't matter.  BLOCKs act like files with the same name.  It just
isn't as easy to write a complete program for separate files :-)

With separate files, all you need to take care for is your
INCLUDE_PATH setting: there is no such thing as a "relative URL" in
TT, you need to explicitly list the directory where template B
resides.  And, as I wrote before, please inspect the error string from
TT's process() method.
-- 
Cheers,
haj

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to