In Grails, GSPs are HTML pages with embedded executable code. At runtime, Grails executes the code, replaces it with the results of the execution, and renders the resulting as HTML.
create the taglib file in grails-app/taglib with any name also we create the taglib with command in terminal :
grails create-taglib [name]
eg. grails create-taglib Book
1 2 3 4 5 6 7 8 9 |
class BookTagLib { static namespace = "book" def getBookPrice = { attrs -> def bookPrice= attrs.bookId; out << bookPrice } } |
Use in any GSP page or call the custom taglib in gsp page.
<label>Price : </label> <book:getBookPrice></book:getBookPrice>
Now, to use the tagget getBookPrice
action, you should specify the book
namespace as the tag prefix.
Thanks
Recent Comments