Re: About Headers and Footers
Daniel Dekany <ddekany <at> freemail.hu>
2007-06-22 20:33:07 GMT
Friday, June 22, 2007, 4:01:20 PM, Juan Larran wrote:
> Hello,
>
> Ive some experience with FreeMarker and recently i started to use
> fmpp to generate ftl pages from an xml file.
>
> Most of the pages used the same tlds and tags libraries, so I tried to use the header configuration.
>
> The problem that I have its the next one:
>
> From the file fmpp_list.ftl i generate a lot of pages (ie
> product_list_index.ftl, product_list_body.ftl,
> product_list_labels.ftl, product_list_ftl, and so for different
> entities), when I put a header to **/*_body_list.ftl the fmpp didnt
> findd that file and dont put anything. If I put **/*.ftl they put
> the header to fmpp_list.ftl but not for the generated files.
>
> How could I put a header to the generated files?
>
> I generated the files by the command < <at> pp.changeOutputFile inside the fmpp_list.ftl
I guess you misunderstand the header/footer feature. It puts the
header/footer at the top/bottom of the *template* (i.e. FTL) files
before FreeMarker parses them. It doesn't directly affect the output.
It meant to be used for adding commonly used stuff like
<#import ...>-s and <#escape ...>-s to the *templates*, to save key
strokes for the template author. But of curse as it can contain
arbitrary FTL, it can be used for much more.
I suppose you generate multiple output files from a single template in
loop. In that case it's trivial to add a common header to each
*output* file, as you can specify it inside the loop:
<#list ....>
< <at> pp.changeOutputFile ... />
You common header comes here.
Other non-header stuff comes here.
</#list>
Now, if you want to control these common *output* file headers using
the FMPP "borders" setting, then you could specify a header there like
this:
<#macro commonHeader>
You common header comes here. It can contain markup,
interpolations, directive calls, etc.
</#macro>
Note again that this will be the header of *templates*. It will define
(not execute) a "commonHeader" macro in each templates whose header it
is, but it will not output anything yet. Then inside the output file
loop you can do this:
<#list ....>
< <at> pp.changeOutputFile ... />
< <at> commonHeader /> <#-- Now it is actually printed -->
... other non-header stuff ...
</#list>
--
--
Best regards,
Daniel Dekany
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/