Created
November 20, 2015 04:40
-
-
Save eginez/adaf5a07a6226a7097eb to your computer and use it in GitHub Desktop.
grails taglib to create groovy templates inside a gsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use the taglib in your gsps like so
<g:gtrender>
div(class: 'my-class') { a('some groovy template action') }
<g:gtrender>