Re: Desired Features in FreeMarker

Attila Szegedi <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
On 2008.01.17., at 19:32, mraible wrote:

> 1. When doing the JSP-based prototype with Struts 2, I was able to  
> use JSP
> 2.0 tag files to develop a <foo:body> tag that allows content to be  
> added
> around the body of the page. Does FreeMarker offer something  
> similar, or is
> it something like SiteMesh the only solution?

Would macros with [#nested] directive help? I.e.

[#macro body]
mybodyprologue
[#nested]
mybodyepilogue
[/#macro]

[@body]
foo
[/@]

would emit:
mybodyprologue
foo
mybodyepilogue


> 2. Is it possible to add static imports/methods to a context so
> "url(foo).q(bar)" can be used instead of referring to the object that
> contains the methods - "urlBuilder.url(foo).q(bar)"?

Well, methods are first-class objects, so a

[#assign url = urlBuilder.url/]

will give you this. You can get to this from Java code too and set it  
as shared variables in a Configuration if you want them to be  
automatically available to templates. As for exposing static methods  
in your templates, see "Accessing static methods" in <http://www.freemarker.org/docs/pgui_misc_beanwrapper.html 
 >

> 3. Is it possible to change how HTML is parsed so you can override or
> customize the [a href=""/] tag? The current compiler does this and  
> it allows
> more fine-grained control over template processing without requiring  
> new
> macros to be called.

FreeMarker doesn't parse HTML. I'm not sure I understand this question.

> Thanks for any information you can provide.

You're welcome -- I hope the above were helpful pointers. If not,  
we'll happily help you further.

Attila.

> Matt

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.