Luccas
Luccas

Reputation: 4278

Get template rendered from controller without render yet

I want to return my response as JSON with ajax containing more atributtes instead only the template:

Default:

render(template:"/templates/question",model:[question: question])

..and want something like:

def template = *get*(template:"/templates/question",model:[question: question])
    render [template:template, isTemplate: true] as JSON

Is that possible? Thanks

Upvotes: 1

Views: 428

Answers (1)

Luccas
Luccas

Reputation: 4278

Then the solution is:

class MyController { 
  def test = {
        // stored as string ... 
        def x = g.render(template:"/basecontroller/test",model:[name:"wysmedia.com"]); 
        render(x); // display the template instead render 
  }
}

Upvotes: 1

Related Questions