Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please upgrade groovy from 2.3.3 #78

Open
svsa opened this issue Dec 9, 2014 · 0 comments
Open

Please upgrade groovy from 2.3.3 #78

svsa opened this issue Dec 9, 2014 · 0 comments

Comments

@svsa
Copy link

svsa commented Dec 9, 2014

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

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant