Details
Description
I have the following tag lib:
class MyTagLib {
static namespace = 'my'
def tag1 = { attrs ->
out << out.getClass().name << ": [" << attrs.p1 << "] [" << attrs.p2 << "]"
}
def tag2 = { attrs ->
out << my.tag1(p1: "abc")
}
}
And the following gsp:
<p>This is tag1: <my:tag1 p1="abc"/></p>
<p>This is tag2: <my:tag2/></p>
The output looks like this:
This is tag1: org.codehaus.groovy.grails.web.pages.GSPResponseWriter: [abc] []
This is tag2: org.codehaus.groovy.grails.web.taglib.GroovyPageTagWriter: [abc] [null]
The behavior of out << null is different between GSPResponseWriter and GroovyPageTagWriter. It seems inconsistent to me.
I just realized that you don't even need to call tag1 from tag2...
You can simply use the 'method call way' from the gsp directly:
<p>This is tag1 from method call: ${my.tag1(p1: 'abc')}</p>which produces the result:
This is tag1 from method call: org.codehaus.groovy.grails.web.taglib.GroovyPageTagWriter: [abc] [null]<p>This is tag1 from method call: ${my.tag1(p1: 'abc')}</p>This is tag1 from method call: org.codehaus.groovy.grails.web.taglib.GroovyPageTagWriter: [abc] [null]