Re: About Headers and Footers
Daniel Dekany <[email protected]> Fri, 22 Jun 2007 22:33:07 +0200
| Newsgroups | gmane.comp.text.fmpp |
|---|---|
| Message-ID | <[email protected]> |
Friday, June 22, 2007, 4:01:20 PM, Juan Larran wrote:
> Hello,
> =
> I=92ve 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 us=
e the header configuration.
> =
> The problem that I have it=92s 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 didn=92t
> findd that file and don=92t 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 <@pp.changeOutputFile inside the fmp=
p_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 ....>
<@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 ....>
<@pp.changeOutputFile ... />
<@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/