Discussion:
[FreeMarker-user] Setting request scope variables from within macro
Marc Schipperheyn
2012-12-04 13:59:24 UTC
Permalink
Hi,

I'm trying and failing to set a request scope variable from within a macro.

I've tried
<#global delayPhoto = 0>
<#macro delayedPhoto photo path type="thumb" >
<#if (.globals.delayPhoto > 0)>
<#global delayPhoto = .globals.delayPhoto + 1>
<#else>
<#global delayPhoto = 1>
[...]

<#global delayPhoto = 0>
<#macro delayedPhoto photo path type="thumb" >
<#if (delayPhoto > 0)>
<#global delayPhoto = delayPhoto + 1>
<#else>
<#global delayPhoto = 1>
[...]

and some other variations but delayPhoto always
remain 0 when the macro is called.

How do I set a request scope variable from within a macro?
echineselearning
2012-12-07 05:51:27 UTC
Permalink
Heritage learners Chinese: Give you a Chinese name
As heritage Chinese learners <http://www.echineselearning.com/> ,
you will most likely to want to get a Chinese translation of their English
name. This will help the people they are doing business with to pronounce
their name as well as remember it. (http://www.echineselearning.com/)
It is also a great show of respect for your business associate’s customs and
culture. Another reason to get a Chinese name is if you intend to travel to
China or even just for fun. (http://www.echineselearning.com/)
Most people can write their name, but not everyone can write their name in
more than one language. Heritage learners Chinese
<http://www.echineselearning.com/> have a Very solid basic literacy in
Chinese! Most of them have the same things with Chinese.
(http://www.echineselearning.com/)
Chinese and English differ phonetically, orthographically and grammatically.
As a result, the way you write and pronounce your name in Chinese is
different to how you would when speaking English. To write your name in
Chinese calligraphy you must learn Chinese by writing its characters have a
Chinese version of your name and develop your Chinese calligraphy skills.
What do you think about the heritage learners Chinese?
<http://www.echineselearning.com/> Come and have a try.
You can drill you skills at http://www.echineselearning.com/ to learn
Chinese.




--
View this message in context: http://freemarker.624813.n4.nabble.com/Setting-request-scope-variables-from-within-macro-tp4654407p4654408.html
Sent from the freemarker-user mailing list archive at Nabble.com.
Daniel Dekany
2012-12-08 13:30:18 UTC
Permalink
It should work with both variations. But, maybe there's a
misunderstanding regarding the life-cycle of the global scope here.
When your top-level template terminates, the global scope will be
released. It doesn't correspond to the request.

FreeMarker has no concept of Request-s or anything that's HTTP- or
Servlet-related. So how do you read or write the Request attributes
(if you can at all) is up to the Web Application Framework authors (or
to the application authors).
--
Best regards,
Daniel Dekany
Post by Marc Schipperheyn
Hi,
I'm trying and failing to set a request scope variable from within a macro.
I've tried
<#global delayPhoto = 0>
<#macro delayedPhoto photo path type="thumb" >
<#if (.globals.delayPhoto > 0)>
<#global delayPhoto = .globals.delayPhoto + 1>
<#else>
<#global delayPhoto = 1>
[...]
<#global delayPhoto = 0>
<#macro delayedPhoto photo path type="thumb" >
<#if (delayPhoto > 0)>
<#global delayPhoto = delayPhoto + 1>
<#else>
<#global delayPhoto = 1>
[...]
and some other variations but delayPhoto always
remain 0 when the macro is called.
How do I set a request scope variable from within a macro?
Loading...