Andreas
Andreas

Reputation: 400

Using a taglib tag with MarkupBuilder

I try to call a Grails Tablib in combination with the Groovy MarkupBuilber

MarkupBuilder html = new MarkupBuilder(out)

html.div {
    g.link(controller: "...", action: "...") {
        ...
    }
}

As described in the Grails documentation (http://docs.grails.org/latest/guide/theWebLayer.html#_rendering_a_response) this is not working because the taglib call return some text that will be ignored by the MarkupBuilder

I also found this issue in the grails-gsp project on github (https://github.com/grails/grails-gsp/issues/7) with the same problem. In this issue the solution is to use out <<.

Is this the correct solution and right way or are there other possibilities?

Upvotes: 1

Views: 185

Answers (1)

practical programmer
practical programmer

Reputation: 1648

Just use mkp.yield or mkp.yieldUnescaped for custom text added to builder syntax.

MarkupBuilder html = new MarkupBuilder(out)

html.div {
    mkp.yieldUnescaped g.link(controller: "...", action: "...") {
        ...
    }
}

Upvotes: 3

Related Questions