Re: First template attempt: how to INCLUDE a list of subfiles?

Tom Molesworth <tom-UE50auxAeIt4LjgWlUEQQwC/[email protected]> Mon, 17 Dec 2012 11:30:48 +0000
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <[email protected]>
On 17/12/12 10:49, Dave Howorth wrote:
> Michael Friendly wrote:
>> This is my first attempt to use the Template system & tpage to refactor
>> some old
>> web pages to make them more flexible for further development.
>> The web page I'm working on is at
>> http://www.datavis.ca/gallery/missed.php
>> and I simply want to generate each of the table rows from a template
>> file, that looks like that below.
>>
>> There's probably something very basic I'm missing, but the lines
>> [% FOREACH item IN items %]
>>      [% INCLUDE item %]
>> [% END %]
>> produce no output in the tpage generated file.
> It's a little awkward to answer clearly without running the risk of
> offending you, so please don't take offence ...
>
> The big question and the most likely reason you're not seeing anything
> is that your items do not contain what TT expects.

I think the issue here is just the missing $ in the INCLUDE directive:

[% FOREACH item IN items %]
     [% INCLUDE item %]
[% END %]

should be:

[% FOREACH item IN items %]
     [% INCLUDE $item %]
[% END %]


otherwise it'll look for the block/file called "item".

cheers,

Tom