grailsgsp

<g:if> logical or condition


In grails gsp, instead of

<g:if env="development">
     <h1> xyz </h1>
</g:if>
<g:if env="production">
     <h1> xyz </h1>
</g:if>

is it possible to write logical or condition in <g:if> to combine the two conditions

for example

<g:if test="env='production'"||"env='devlopment'">
    <h1> xyz </h1>
</g:if>

What's the right way of doing that?


Solution

  • Just for the sake of DRYness:

    <%@ page import="grails.util.Environment" %> 
    <g:if test="${Environment.current in 
                    [Environment.PRODUCTION, Environment.DEVELOPMENT]}">
        <h1>xyz</h1>
    </g:if>