Re: Pass through of optional parameters
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Wednesday, May 14, 2008, 6:28:58 PM, Daniels, Troy (US SSA) wrote: >> -----Original Message----- >> From: [email protected] >> [mailto:[email protected]] On >> Behalf Of Daniel Dekany >> Sent: Wednesday, May 14, 2008 4:22 AM >> To: FreeMarker-user >> Subject: Re: [FreeMarker-user] Pass through of optional parameters >> >> Wednesday, May 14, 2008, 10:01:00 AM, Attila Szegedi wrote: >> >> > *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? >> >> I my un-implemented language there is, shown with FTL syntax: >> >> <@theMacro theParam!noarg> >> >> So, there was special value (special like null is) that means >> that the parameter (or list/map item!) is omitted. Overly >> smart, one could say... but also quite useful. But it still >> doesn't solve that the user has requested in this thread. The >> thing is, if you do know that a variable potentially missing, >> you have to indicate that in the source code everywhere you >> refer to that variable; it has trivial maintainability >> related reasons, so I'm reluctant to give it up. > > In my case, if I get to a point where I want to use the optional > variable and it's not there, it's a bug (either in the template or the > input) and dieing horribly is an acceptable response. Then it sounds like we agree here. So you don't want <@foo optionalVariable> to work when the parameter is optional, right? >> I don't see >> how could it be a reason to relieve this rule that the >> variable reference happens to be used as a parameter. Now, in >> the case of FreeMarker 2.3, the problem is, that even if the >> user accepts this philosophy of strictness, he simply can't >> indicate that "I know this variable is possibly missing, and >> in that case please consider the whole parameter being >> omitted". But starting from FreeMarker 2.4, you can write >> theParam?null. > > What's the timeline for 2.4 being released? It will be released "when it's done"... But I guess late September is realistic. >> It's a dirty solution, as it doesn't exactly >> behave as if the parameter were omitted, but practically it >> will be OK on the quality standard where FreeMarker lives. >> > > It will certainly work well enough for me. > > Troy -- Best regards, Daniel Dekany ------------------------------------------------------------------------- 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/