User defined directives as first-class citizens & WRAPPER directive
Phil Ventura <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Our development team is currently working on moving from the (Perl-based)
Template Toolkit to Freemarker. One of the directives that Template Toolkit
provides and is used in a large number of our existing template files is
named WRAPPER (
http://template-toolkit.org/docs/manual/Directives.html#section_WRAPPER).
Here's the basic idea implemented as a Freemarker macro:
<#macro wrapper include>
<#local content>
<#nested>
</#local>
<#include include>
</#macro>
So, given the .ftl files,
wrapper.ftl:
header info
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
${content}
----------------------------------------------------------------------
footer info
and, simple.ftl:
<@wrapper include="/wrapper.ftl">
<p>Wrap this.</p>
</wrapper>
It produces:
header info
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<p>Wrap this.</p>
----------------------------------------------------------------------
footer info
Since our production team uses WRAPPER so frequently, I'd like to be able to
add it as a directive. However, when reading up on creating my own
directive in Java (
http://freemarker.sourceforge.net/docs/pgui_datamodel_directive.html) it
appears that the syntax for using a user defined directive is different from
that used for the built-in directives.
So, my question is, are there plans to make (Java) user defined directives
to use the same syntax as the built-ins? If so, how soon is this expected?
If not, is there interest in adding a WRAPPER directive to the built-ins?
Looking at the source, it appears that it simply requires a change to the
JavaCC grammar together with a class definition both of which are similar to
what is done with Include.
--
Phil Ventura, Ph.D.
Software Engineer
Research & Development Group
Velocitude
Fort Lauderdale, FL
------------------------------------------------------------------------------
_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user