Details
Description
With the following tags
def test1 =
{
attrs ->
log.debug "test1 ${attrs}"
out << "test1 ${attrs}"
}
def test2 =
{
attrs ->
log.debug "test2 ${attrs}"
out << "test2 ${attrs}"
test1()
}
this works
<g:test1 test="test1"/> <g:test2 test="test2"/>
it generates the following html
test1 ["test":"test1"] test2 ["test":"test2"]test1 null
and the following logging
DEBUG btpool0-1 12:43:52,012 grails.app.tagLib.OurFormTagLib | test1 ["test":"test1"] DEBUG btpool0-1 12:43:52,028 grails.app.tagLib.OurFormTagLib | test2 ["test":"test2"] DEBUG btpool0-1 12:43:52,028 grails.app.tagLib.OurFormTagLib | test1 null
But when I add an argument to the call from tag test2 to tag test1
def test1 =
{
attrs ->
log.debug "test1 ${attrs}"
out << "test1 ${attrs}"
}
def test2 =
{
attrs ->
log.debug "test2 ${attrs}"
out << "test2 ${attrs}"
test1( attrs ) // Introduced the argument to tag test1
}
The same
<g:test1 test="test1"/> <g:test2 test="test2"/>
does not work anymore, it generates the following in the html
test1 ["test":"test1"] test2 ["test":"test2"]
But the logging is correct
DEBUG btpool0-1 12:49:36,438 grails.app.tagLib.OurFormTagLib | test1 ["test":"test1"] DEBUG btpool0-1 12:49:36,438 grails.app.tagLib.OurFormTagLib | test2 ["test":"test2"] DEBUG btpool0-1 12:49:36,438 grails.app.tagLib.OurFormTagLib | test1 ["test":"test2"]
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
This is not a bug: see section 6.2.2.6 Tags as Method Calls of the user guide. Basically, when you call a tag from a controller or another tag, a string is returned. Therefore the example code should look like this:
class TestTagLib { def test1 = { attrs -> log.info "test1 ${attrs}" out << "test1 ${attrs}" } def test2 = { attrs -> log.info"test2 ${attrs}" out << "test2 ${attrs}" out << test1( attrs ) } }Calling test1() without any arguments should not have worked (and did not when I tested against svn HEAD).