简体   繁体   中英

<g:if> and <g:set>misunderstanding in grails

I have a gsp template. And I have varialble. If this variable is true , then create an additional button, if false - do nothing.

What is wrong with my code?

<g:set var="removeButton">{{ removeButtonPossibility }}</g:set> // variable from model, is true or false
<g:if test="${removeButton == true}">
   <button id="removeDocument">Delete</button>
</g:if>

It doesn't work. But just using: ${removeButton} normally prints true or false .

What about doing the easy thing? :)

<g:set var="removeButton" value="${removeButtonPossibility}" />
<g:if test="${removeButton}">
    <button id="removeDocument">Delete</button>
</g:if>

Or, even better:

<g:if test="${removeButtonPossibility}">
    <button id="removeDocument">Delete</button>
</g:if>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM