Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails link taglib use outside of GSP

I'm trying to use the taglib call there's attribute parameters, but also the stuff inside the tag itself which the link taglib uses. I can't find the attribute to pass in to a g.link() call to have it render the text of the link. I've tried 'body' and 'link' and 'text' and 'linkText' already - none of those work.

I'm expecting to be able to call

g.link(action:"foo", controller:"bar", _____:"text of the link here")

but don't know what to put in _____

like image 597
user111544 Avatar asked Jun 19 '09 19:06

user111544


1 Answers

Usually you do it like this:

g.link(action:"foo", controller:"bar", "text of the link here")

The link text doesn't need to be the last parameter, it may appear anywhere:

g.link("text of the link here", action:"foo", controller:"bar")

.

Usage with closure:

Instead of the string you can use a closure which returns a string:

g.link(action:"foo", controller:"bar", {"text of the link here"})

And, as with any groovy closure which is the last parameter for a method call, you can put it after the closing parentheses:

g.link(action:"foo", controller:"bar") {"text of the link here"}
like image 114
Zim Avatar answered Oct 14 '22 14:10

Zim