After using the Django template language, I really miss being able to do things like this:
{% if condition %}
<!-- snip -->
{% else %}
<!-- snip -->
{% endif %}
When I am using JSP, I am stuck doing something like this:
<logic:equal name="something" value="example">
<!-- snip -->
</logic:equal>
<logic:notEqual name="something" value="example">
<!-- snip -->
</logic:notEqual>
or:
<% if (condition) { %>
<!-- snip -->
<% } else { %>
<!-- snip -->
<% } %>
Is it possible to write a custom tag that supports else
and else if
, rather than simply having a pair of tags for each check?
If it's not possible, which is the "preferred" style? Scriptlets or multiple tag pairs? At my organization, most people seem to frown upon scriptlets, but I haven't really heard a good reason why simple conditional statements like the ones I've listed are so bad.