Grails Cookbook - A collection of tutorials and examples

Grails unless Tag Example

The Grails unless tag (<g:unless>) renders it's body when the condition given is false. It is the opposite of the if tag that renders a body when the condition is true. This will show a simple example on how to use this tag.

Examples

This code:
<g:set var="salary" value="${1000}"/>
<g:unless test="${salary == 1000}">
    Hello World
</g:unless>
Will NOT render the body "Hello World"
But this code:
<g:set var="salary" value="${1000}"/>
<g:unless test="${salary != 1000}">
    Hello World
</g:unless>
Will render the body "Hello World"

Other Grails Tag Examples



Tags: Grails Tag, unless