Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails: Invoking one taglib from within another

Tags:

I want to define my own taglib that will use the g:datePicker to generate some of it's output.

class MyTagLib    def myTag = {attrs ->     // I need to invoke the `datePicker` tag of the the `FormTagLib` tag library     // provided by Grails          } } 

I want to pass along the attributes map when I invoke this tag. When I invoke g:datePicker I would like it to write it's output directly to the response (just as it does when you invoke it within a GSP).

How can I do this? Thanks.

like image 662
Dónal Avatar asked Feb 07 '10 01:02

Dónal


2 Answers

out << g.datePicker(etc...) ought to do it. The other taglib prefixes are metaprogrammed in automatically.

like image 129
John Stoneham Avatar answered Oct 07 '22 10:10

John Stoneham


If you want to add a body, you need to pass a closure: out<<g.link(action: x, {"This is a link to x"}) or out<<g.link(action: x) {"This is a link to x"}

like image 37
Maciek Avatar answered Oct 07 '22 12:10

Maciek