Grails : Tag - render
This page last changed on Feb 17, 2006 by [email protected].
Tag - renderDescriptionApplys an inbuilt or user defined Groovy template against a model so that templates can be re-used for lists or instance or a single instance Parameters
ExamplesExample domain class: Book.groovy class Book { @Property String title @Property String author }
Example template: _displaybook.gsp <p><%= it.title %></p> <p><%= it.author %></p>
This template can now be re-used whether you have a list of books or a single book. For a list the template will be repeated for each instance: <g:render template="displaybook" collection="${books}" />
or <g:render template="displaybook" bean="${book}" />
or you could create a template that handles a certain type of model. For example the template below: <p><%= book.title %></p> <p><%= author.fullName %></p>
Could be used with the model as below. The disadvantage of this technique however is that the template is less re-usable <g:render template="displaybook" model="['book':book,'author':author]" />
|
Document generated by Confluence on Mar 29, 2006 08:46 |