How to build a Custom Include method?
"Jeremy Chone" <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I would like to build a custom include method. Basically, I would like to be
able to call something like:
${customInclude(param1,param2)}
which will include a template almost as a traditional [#include does. There
are two main differences between this customInclude and a traditional
freemarker include:
1) customInclude add another level of indirection to get to the template
name (handled by java business objects)
2) Each customInclude might have a different model.
Today, I have an implementation that works. Basically, I implemented an
TemplateMethodModelEx method (customInclude) which implements the logic to
get the template name, and get the "Writer" object from the param. Then, I
just get the template and call template.process with the givent Writer.
It's ugly, but it work. I hide this method with a macro, so, as the pages do
not have too now about the Writer object/param.
Is there better way for doing this? Can I get some more context in a
TemplateMethodModelEx method ?
Jeremy,
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user