Re: Possible room for performance improvement when using TemplateDirectiveModel and TemplateMethodModelEx

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Saturday, January 15, 2011, 11:40:41 AM, Daniel Henrique Alves Lima wrote:

>         Hi, Daniel.
>
>
> On Sat, 2011-01-15 at 10:52 +0100, Daniel Dekany wrote:
>> Saturday, January 15, 2011, 1:06:26 AM, Daniel Henrique Alves Lima wrote:
>> 
>
>> 
>> TemplateMethodModelEx pretty much corresponds to FTL functions, so
>> yes, it will. (Isn't that how you create them now?) (Note that you can
>> also have objects that implement both TemplateMethodModelEx and
>> TemplateDirectiveModel on the same time.)
>
>         I cannot remember why i haven't use the sample implementation for both.
> If the same class implement both interface, will FreeMarker execute
> TemplateDirectiveModel method for <@x.y> and TemplateMethodModelEx
> method for ${x.y}? Maybe i wasn't aware of this before... :-/

Yes, except that last had to be x.y() of course.

>> (But, of course, if any of these Grails-specific objects are bound to
>> a HTTP Request or HTTP Session, then you can't just create them on the
>> application level.)
>
>         That's why i will try to provide this (shared variables exposure) as an
> option.

You can also put the "g" hash into the data-model in that case (which
makes sense as constructing that hash in Java is certainly faster than
doing the same in FTL, which BTW also includes an #import). If some
member of "g" should be application scope, and some should be request
scope, then you can fall-back to an application scope hash for the
application scope ones.

>> You will lose it. However here the thing that overrides "g" and the
>> affected part of the source code that wants to use "g" are in the same
>> file, which is much less worrisome than if something that comes from
>> outside hides "g".
>
>         Ok.
>
>         Thanks.
>
>
> ------------------------------------------------------------------------------
> Protect Your Site and Customers from Malware Attacks
> Learn about various malware tactics and how to avoid them. Understand 
> malware threats, the impact they can have on your business, and how you
> can protect your company and customers by using code signing.
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>

-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
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.