Is there a more elegant way to do null checks?
damcard <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
In JSTL I can do a null check like so:
<c:if test="${not empty template.scripts.inline.head}">do something</c:if>
Template is a map in the request with a scripts entry. Scripts is a map
with an inline entry. Inline is a map with a head entry. Head is a list of
strings containing a number of scripts to be put in the head. A nice thing
about JSTL is I did not have to worry about if it was null or not.
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
considered making a pre-directive for all my macros that would setup an
empty non null model, ensuring they are never null but don't like that
solution. Thanks for your help. -David.
--
View this message in context: http://n4.nabble.com/Is-there-a-more-elegant-way-to-do-null-checks-tp1689628p1689628.html
Sent from the freemarker-user mailing list archive at Nabble.com.
------------------------------------------------------------------------------
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