`
boogie
  • 浏览: 235630 次
  • 性别: Icon_minigender_1
  • 来自: 宁波
社区版块
存档分类
最新评论

Writing the <g:if> tag in a tag library

阅读更多

The internal if/else tags that come with Grails translate directly
into if(..) {} else {} at the syntax level to improve performance of
such core tags . But you can quite easily write if/else tags using the
pageScope object and Grails' standard tags

for example:

def ifSomething = { attrs, body ->
     pageScope.doElse = !attrs.condition
     if(attrs.condition) out << body()
}
def elseSomething = { attrs, body ->
    if(pageScope.doElse)  out << body()
}

Then

<g:ifSomething condition="${1==2}">yes</g:ifSomething>
<g:elseSomething>no</g:elseSomething>

分享到:
评论

相关推荐

    Visual C++ 编程资源大全(英文源码 其它)

    ShellExtGuide6_demo.zip&lt;br&gt;A tutorial on writing a shell extension that can be used on the Send To menu.(22KB)&lt;END&gt;&lt;br&gt;96,ShellExtGuide7_demo.zip&lt;br&gt;A tutorial on using owner-drawn menus in a context ...

    一个JSP自定义标签的例子。格式化基础数据

    throw new JspException("Error in writing formatted date", e); } } } ``` 这个类继承了`SimpleTagSupport`,并重写了`doTag`方法。该方法负责将传入的日期按照指定的格式进行格式化,并将结果输出到JSP页面中...

    自定义标签

    &lt;description&gt;TagLibrary to support examples webapp&lt;/description&gt; &lt;tlib-version&gt;1.1&lt;/tlib-version&gt; &lt;short-name&gt;my&lt;/short-name&gt; &lt;uri&gt;/mytld&lt;/uri&gt; &lt;tag&gt; &lt;name&gt;ViewIP&lt;/name&gt; &lt;tag-class&gt;...

    testActiveMQ.rar

    * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express...

    Servlets和JSP核心技术 卷2(英文版) 第一部分

    Including Tag Body in the Tag Output Section 7.6. Example: Heading Tag Section 7.7. Example: Debug Tag Section 7.8. Creating Tag Files Section 7.9. Example: Simple Prime Tag Using Tag Files ...

    Servlets和JSP核心技术 卷2(英文版) 第二部分

    Including Tag Body in the Tag Output Section 7.6. Example: Heading Tag Section 7.7. Example: Debug Tag Section 7.8. Creating Tag Files Section 7.9. Example: Simple Prime Tag Using Tag Files ...

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    - FIX: If the TCustomProp.Assign method calls when the undo/redo history writing was in progress, the error occured. - FIX: The TFlexPanel.LoadFlexControl method now virtual. - FIX: The TFlexPanel....

    apktool documentation

    -t, --tag &lt;tag&gt; - Tag frameworks using &lt;tag&gt; Allow for a finer control over how the files are named and how they are stored. $ apktool if framework-res.apk I: Framework installed to: 1.apk // ...

    数位板压力测试

    Writing simple programs should require only a few lines of code and a minimal understanding of the en-vironment. On the other hand, more advanced features and functions should be available to those ...

    acpi控制笔记本风扇转速

    The disassembler now emits a comment if a buffer appears to be a ResourceTemplate, but cannot be disassembled as such because the EndTag does not appear at the very end of the buffer. AcpiExec - ...

    WPTools.v6.29.1.Pro

    * HTML writer writes img tag also for empty images IF a name is provided in event PrepareImageforSaving * HTML reader does not add space at end anymore - the UNICODE reader uses attribute of current ...

    php.ini-development

    If you use constants in your value, and these constants belong to a ; dynamically loaded extension (either a PHP extension or a Zend extension), ; you may only use these constants *after* the line ...

    微软内部资料-SQL性能优化2

    A 32-bit process is normally limited to addressing 2 gigabytes (GB) of memory, or 3 GB if the system was booted using the /3G boot switch even if there is more physical memory available. By leveraging...

    django-master-class

    - **Tag Registration:** Custom tags must be registered in a template tag library using the `register` object. - **Common Use Cases:** - Displaying paginated content. - Generating navigation menus ...

    Manning.Spring.in.Action.4th.Edition.2014.11.epub

    2.4.2. Declaring a simple &lt;bean&gt; 2.4.3. Initializing a bean with constructor injection 2.4.4. Setting properties 2.5. Importing and mixing configurations 2.5.1. Referencing XML configuration in Java...

    Bochs - The cross platform IA-32 (x86) emulator

    - display library 'x' now uses the desktop size for the maximum guest resolution - ROM BIOS - Support for up to 2M ROM BIOS images - I/O Devices - 3 new 'pseudo device' plugins created by plugin ...

    SynPDF-master 2016-07-12

    In fact, you have at least three ways of generating pdfs using the library: * [Directly call](http://synopse.info/forum/viewtopic.php?pid=370#p370) of a `TPdfCanvas` as published by a `TPdfDocument` ...

    FastReport.v4.15 for.Delphi.BCB.Full.Source企业版含ClientServer中文修正版支持D4-XE5

    + [enterprise] added property "Scheduler" - "Debug" in server configuration - enable writing of debug info in scheduler log + [enterprise] added property "Scheduler" - "StudioPath" in server ...

    ARM® Compiler v5.06 for µVision® armasm User Guide

    1.4 Directives that can be omitted in pass 2 of the assembler 2 Overview of the ARM Architecture 2.1 About the ARM architecture 2.2 ARM, Thumb, and ThumbEE instruction sets 2.3 Changing between ARM, ...

    《JVoiceXML 0.7 用户指南》-电子文档下载(PDF)(英文)

    9 Creating VoiceXML using the Tag Library 10 9.1 Creating the Servlet . . . . . . . . . . . . . . . . . . . . . . . 10 9.2 Creating the WAR Archive . . . . . . . . . . . . . . . . . . . 12 9.3 ...

Global site tag (gtag.js) - Google Analytics