开发者

Get template rendered from controller without render yet

开发者 https://www.devze.com 2023-02-11 12:44 出处:网络
I want to return my response as JSON with ajax containing more atributtes instead only the template: Defa开发者_如何学Goult:

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

Defa开发者_如何学Goult:

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


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 
  }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消