Re: Is there a more elegant way to do null checks?
David McArdle <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Awesome, thanks guys. That really simplified things. -David On Wed, Mar 24, 2010 at 4:50 PM, Newman, John W <[email protected] > wrote: > The ! operator is the best > > ${(patient.name.first)!"<Not Entered>"} > > [#list (patient.diagnoses)![] as dx] > ${(dx.code)!"<Unknown>"} > [/#list] > > [#if (template.scripts.inline.head)!{}?has_content] > Do something > [/#if] > > For the last one there I am not 100% on the order of precedence, you may > need an extra paren before the ? > > > -----Original Message----- > From: Jan Haderka [mailto:[email protected]] > Sent: Wednesday, March 24, 2010 4:52 PM > To: FreeMarker-user > Subject: Re: [FreeMarker-user] Is there a more elegant way to do null > checks? > > > When I rewrote my tag files as macros, I produced a lot of bloated template > code like so: > > [#if (template?? && template.scripts?? && template.scripts.inline?? && > template.scripts.inline.head??)]do something[/#if] > > Is there a more elegant way to check if the head value is empty? I have > > I'm not an expert, but would not something like: > > [#if (template.scripts.inline.head)??]do something[/#if] > > do? > > Jan > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > FreeMarker-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/freemarker-user > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > FreeMarker-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/freemarker-user > ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ FreeMarker-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freemarker-user