vert-x / mod-lang-groovy

Vert.x 2.x is deprecated - use instead
https://github.com/vert-x3/vertx-lang-groovy
Other
16 stars 15 forks source link

Please upgrade groovy from 2.3.3 #78

Open svsa opened 9 years ago

svsa commented 9 years ago

MarkupTemplateEngine has a bug in groovy 2.3.3 where the properties are not propagated properly making the template system fairly unusable.

Example code used from mrhaki: http://mrhaki.blogspot.co.uk/2014/08/groovy-goodness-using-layouts-with.html

Using his main.tpl, this is the routeMatcher in server.groovy:

routeMatcher.getWithRegEx('.*') { req ->

// Create engine with configuration.
TemplateConfiguration config = new TemplateConfiguration(autoIndent: true, autoNewLine: true)
MarkupTemplateEngine engine = new MarkupTemplateEngine(config)

// Create template with layout reference
// and values for layout variables.
Template template = engine.createTemplate('''\
layout 'layouts/main.tpl', true,
    pageTitle: 'Welcome',
    mainContents: contents {
        h1 'Home'
    },
    actions: contents {
        ul(class: 'actions') {
            ['Home', 'About'].each { li it }
        }
    }
''')

// Render output for template.
Writer writer = new StringWriter()
Writable output = template.make([pubDate: Date.parse('yyyyMMdd', '20140801')])
output.writeTo(writer)
String result = writer.toString()

req.response.end result

}