Re: weird macro params issue
Attila Szegedi <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
The order of populating defaulted variables is undefined -- they're
being pulled out by an iterator out of a hash map. So if this worked
for you, then you just had blind luck so far, I'm afraid. That's
something we could maybe enforce going forward...
Attila.
On 2008.05.02., at 10:58, John Cherouvim wrote:
> Hello
>
> I have this macro:
> <#macro test a b=a c=b>
> ${a} - ${b} - ${c}
> </#macro>
>
> And this client code:
> <@test 1 /><br/>
> <@test 1 2 /><br/>
> <@test 1 2 3 /><br/>
>
> Which produces:
> 1 - 1 - 1
> 1 - 2 - 2
> 1 - 2 - 3
>
> Now if I just change the param names of the macro:
> <#macro test foo bar=foo baz=bar>
> ${foo} - ${bar} - ${baz}
> </#macro>
>
> And keep the same client code, then the output produced is:
> InvalidReferenceException: Expression bar is undefined on line 20,
> column 31 in index.ftl.
> 1 - 2 - 2
> 1 - 2 - 3
>
> The first call fails when it tries to evaluate the baz=bar. Why is
> that?
>
> Also, is this usage valid in freemarker? To have parameters default to
> the value of other parameters. I find it very useful for some use
> cases.
>
> thanks,
> Ioannis
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save
> $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
Attila.
--
home: http://www.szegedi.org
weblog: http://constc.blogspot.com
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone