Search code examples
grailsgrails-2.0

Render a controller into a String


I can render a template or a view into a String, but how can I render a controller into a String ?

I would like to perform this kind of operation:

def myAction = {
  ...
  def html = renderToString(controller: 'myController', action: 'myAction', params: [what:'ever'])
  render modify(html)
  ...
}

Solution

  • You can use grails include tag for this

    def html= g.include(controller: 'myController', action: 'myAction', params: [what:'ever'])