gpt4 book ai didi

json - 从 Controller 获取尚未渲染的模板

转载 作者:行者123 更新时间:2023-12-02 14:47:20 27 4
gpt4 key购买 nike

我想使用包含更多属性而不是模板的ajax将响应返回为JSON:

默认:

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

..想要类似的东西:
def template = *get*(template:"/templates/question",model:[question: question])
render [template:template, isTemplate: true] as JSON

那可能吗?
谢谢

最佳答案

那么解决方案是:

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

关于json - 从 Controller 获取尚未渲染的模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5033929/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com