Grails
  1. Grails
  2. GRAILS-1903

When calling one tag from the other with arguments, no output is generated

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.0-RC2
    • Fix Version/s: 1.0-RC4
    • Component/s: TagLib
    • Labels:
      None

      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

        Hide
        Peter Ledbrook added a comment - - edited

        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).

        Show
        Peter Ledbrook added a comment - - edited 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).

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            René de Bloois
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development