Skip to content

Instantly share code, notes, and snippets.

@nithril
Created February 21, 2011 19:59
Show Gist options
  • Save nithril/837614 to your computer and use it in GitHub Desktop.
Save nithril/837614 to your computer and use it in GitHub Desktop.
class UICompositionTagLib {
static namespace = 'ui'
def out
def composition = { attrs, body ->
if (!attrs.template) {
throwTagError("Tag [composition] is missing required attribute [template]")
}
Composition composition = new Composition()
body(composition)
out << g.render(template: attrs.template, model: composition.defines)
}
def define = { attrs, body ->
if (!attrs.composition) {
throwTagError("Tag [define] is missing required attribute [composition]")
}
if (!attrs.name) {
throwTagError("Tag [define] is missing required attribute [name]")
}
attrs.composition.defines.put(attrs.name, body)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment