Skip to content

Instantly share code, notes, and snippets.

@eginez
Created November 20, 2015 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eginez/adaf5a07a6226a7097eb to your computer and use it in GitHub Desktop.
Save eginez/adaf5a07a6226a7097eb to your computer and use it in GitHub Desktop.
grails taglib to create groovy templates inside a gsp
package com.mtail.taglib
import groovy.text.markup.MarkupTemplateEngine
class GroovyTemplateTagLib {
//static encodeAsForTags = [tagName: [taglib:'html'], otherTagName: [taglib:'none']]
def markupEngine = new MarkupTemplateEngine()
def gtrender = { attrs, body ->
markupEngine.createTemplate(body()).make().writeTo(out)
}
}
@eginez
Copy link
Author

eginez commented Nov 20, 2015

You can use the taglib in your gsps like so
<g:gtrender>
div(class: 'my-class') { a('some groovy template action') }
<g:gtrender>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment