Harald Joerg wrote:
> Emmanuel Quevillon writes:
> 
>> I am quite new to template toolkit.
>> I a trying to include a template into another one and use
>> PROCESS to do it.
>>
>> my first template (A) has some html code
>> my second template (B) has some html code too.
>>
>> This how I try to use it:
>>
>> A:
>> ===
>>
>> <html>
>> ...
>> [% FOREACH foo IN bar %]
>> ..
>> [% PROCESS B item = foo.items %]
>> ...
>>
>> [% END %]
>> ...
>> </html>
>>
>> B:
>> ===
>>
>> [% FOREACH i IN item %]
>>
>> [% i.name %]
>>
>> [% END %]
>>
>>
>> However, doing it this way, it returns nothing at all, not
>> even the HTML code produced before the PROCESS directive.
>> I know, from the Manual, that it is possible to pass some
>> parameters to PROCESS.
>>
>> So I wonder if I am doing something wrong?
> 
> 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?

Thanks a lot.
Regards

Emmanuel


-- 
-------------------------
Emmanuel Quevillon
Softwares and Data banks
Institut Pasteur
+33 1 44 38 95 98
tuco at_ pasteur dot fr
-------------------------

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

Reply via email to