Re: Pass through of optional parameters
Attila Szegedi <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
*Sigh*. No, you can't do it, as FreeMarker mandates that all
expressions used as arguments to a macro invocation resolve to a
defined value. I wish we'd change that, at least for optional arguments.
Jonathan, Daniel - opinions?
Attila.
On 2008.05.13., at 20:53, Troy Daniels wrote:
>>
>> I have a macro with an optional parameter:
>>
>> <#macro term source result op context optional...>
>> do stuff, possibly using ${optional.root} </#macro>
>>
>> This is called indirectly by another macro.
>>
>> <@indirectCall root=someValue />
>>
>> <#macro indirectCall optional... > stuff <@term source=s result=r
>> op=o
>> context=c ???/> </#macro>
>>
>> I'd like to pass through the optional parameter when it's given to
>> indirect. At the moment, the best way that I can see to do that is
>>
>> <#macro indirectCall optional... >
>> stuff
>> <#if optional.root??>
>> <@term source=s result=r op=o context=c root=optional.root />
>> <#else
>> <@term source=s result=r op=o context=c />
>> </#if>
>> </#macro
>>
>> Is there a more concise way of doing this? I tried <@term {other
>> args} optional=optional>, but that just meant that the optional map
>> in
>> @term had a key called optional, pointing to the map I wanted it to
>> be.
>>
>> I can write it like this, but it rather clutters macros that aren't
>> trying to do anything except convey the optional parameters down.
>> It'll get even more cluttered if I add a second optional parameter.
>>
>> Troy
>
>
> Also, does anyone know if the
> [email protected] address is active? I
> tried
> posting this from my work account (which receives messages just fine)
> but I got a bounce message like I wasn't subscribed. I sent mail
> there
> asking about the problem, but I haven't heard back from it.
-------------------------------------------------------------------------
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/