page banner
avatar
'Dynamically add and remove HTML blocks with Grails tag library and JQuery' post illustration
Dynamically add and remove HTML blocks with Grails tag library and JQuery

This post shows how to create Grails tag library for adding and removing identical HTML blocks, which can be used when you want to give user an option to dynamically add extra inputs for additional information. There are lots of simple JQuery and pure JavaScript solutions for this feature, but, in general, they are not flexible and clean enough for a Grails application. Pure tag library approach helps to avoid HTML and JS clutter in a GSP file and speeds up the development, since the only thing you need is to specify the tag with necessary parameters.

avatar
'Creating custom GSP tags and tag libraries in Grails' post illustration
Creating custom GSP tags and tag libraries in Grails

Grails tag libraries are designed to provide content formatting capabilities right on a GSP page. The 'tag' is an action that can be declared in a form of an HTML element. This action can accept an enclosed content and parameters defined as the element attributes to render a modified HTML. For instance, the following built-in tag iterates and renders each element of the list object using the template specified in the content: