Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6521

GStringTemplateEngine shares binding

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • None
    • 2.2.2
    • None
    • None

    Description

      The following test case fails, because GStringTemplateEngine doesn't handle the binding correctly. It is shared among calls:

          void testShouldNotShareBinding() {
              String text = "<% println delegate.books; books = books.split(\",\"); out << books %>";
      
              StringWriter sw = new StringWriter();
              GStringTemplateEngine engine = new GStringTemplateEngine();
      
              Template template = engine.createTemplate(text);
      
              Map data = [books: 'a,b,c,d']
      
      
              // round one sucess
              template.make(data).writeTo(sw);
              assert sw.toString() == '[a, b, c, d]'
      
              sw = new StringWriter();
              // round two fails
              data = [books: 'e,f,g,h']
              template.make(data).writeTo(sw);
              assert sw.toString() == '[e, f, g, h]'
      
          }
      
      

      Attachments

        Activity

          People

            melix Cédric Champeau
            melix Cédric Champeau
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: