Re: how to not call a macro if the varialbe is null?
Daniel Dekany <[email protected]> Sun, 29 Dec 2013 15:11:01 +0100
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
There's no null concept in FTL 2.3; it's the same as "undefined" for it. As such, you can use a the existence operators to handle nulls. <#if variable??>, or if you want to provide a default instead (say, 0, but it can be anything), <@u.someThing variable2!0 />. As of the second question, macro parameters can have a default value: <#macro listUsers users arg2=someExpressionHere arg3> -- Thanks, Daniel Dekany Friday, December 27, 2013, 11:35:22 PM, S Ahmed wrote: > Also in the call to: > > <@u.listUsers users variable2 variable3 /> > > I want to make variable2 nullable, is that possible or it has to be a required param? > > > On Fri, Dec 27, 2013 at 5:34 PM, S Ahmed <[email protected]> wrote: > I am calling a macro like this: > > <@u.listUsers users variable2 variabe3 /> > > > And inside of listUsers.ftl I have: > > .. > .. > > <@v.someThing varaible2 /> > > > Now say variable2 is null, is it possible to do soething like: > > if variable2 != null > { > <@v.someThing variable2 /> > } > > > meaning, don't call this macro if the varialbe is null. > > > ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk