Re: Several doubtful points on the manual

Denis Bredelet <[email protected]> Sat, 09 Mar 2013 14:14:06 +0000
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
On 9 Mar 2013, at 13:17, Albert Kam <[email protected]> wrote:

> I have several points to ask based on the manual, please share your views :
> 
> (1) http://freemarker.sourceforge.net/docs/dgui_datamodel_types.html
> > The main reason is that the result of functions are subject to automatic XML-escaping (due to the nature of ${...}), 
> Is it true that the function return value and the result of interpolation are automatically escaped ?

It is subject to escaping *if* you use #escape. Not so for macro calls. 

> I tried this :
> <#assign myvar="hello&world">
> 
> <#function hello>
> <#return "<inside&function">
> </#function>
> 
> ${myvar}
> ${hello()}
> 
> with this result :
> hello&world
> <inside&function
> 
> > while the output of user-defined directives are not (due to the nature of <@...>; its output is assumed to be markup, and hence already escaped).
> Is it true that user defined directives are automatically escaped also ? But i think not, since we have the ?html and #escape for this, am i right ?
> 
> (2) http://freemarker.org/docs/dgui_misc_userdefdir.html
> > also you can use complex expression on the left side of = (e.g. someParam=(price + 50)*1.25)
> Should be on the --right-- side instead of the --left-- side ?

Yes. 

> 
> (3) http://freemarker.org/docs/dgui_template_valueinsertion.html 
> > Guide for inserting date/time values
> > If the expression evaluates to a date then the numerical value will be transformed to a text according to a default format.
> Should be the --date-- value instead of --numerical-- value ?

Technically dates are usually time stamps since the epoch, but I agree with you. 

> 
> (4) http://freemarker.sourceforge.net/docs/dgui_misc_whitespace.html
> > It is useful for templates that contain macro definitions only (and some other non-outputting directives), because it removes the line-breaks that you use between the macro definitions and between the other top-level directives to improve the readability of the template
> How is it improving the readability of the 'library' template when what the developer see is always the unparsed version ?

Exactly, this allows you to add newlines in the template without breaking the layout. Hence it improves readability. 

> 
> Regards from Jakarta,
> Albert
> -- 
> Do not pursue the past. Do not lose yourself in the future. 
> The past no longer is. The future has not yet come. 
> Looking deeply at life as it is in the very here and now, 
> the practitioner dwells in stability and freedom.
> (Thich Nhat Hanh)
> ------------------------------------------------------------------------------
> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
> endpoint security space. For insight on selecting the right partner to 
> tackle endpoint security challenges, access the full report. 
> http://p.sf.net/sfu/symantec-dev2dev
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user

------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev

_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user