Sprox 形式与 Turbogears,使用 Mako,仅显示纯文本
我正在使用 Turbogears 2.1 生成 Sprox 表单并尝试在 Mako 模板中显示它。这是我的代码:
定义表单:
class NewUserForm(AddRecordForm):
__model__ = User
newuserform = NewUserForm(DBSession)
分配表单并调用模板的控制器定义:
@expose('limelight.modules.users.templates.register')
def register(self, **kw):
tmpl_context.register_form = newuserform
return dict(value=kw)
以及相关的模板代码:
${tmpl_context.register_form(value=value)}
问题是 HTML 代码在页面上显示为纯文本,而不是呈现的 HTML。
I'm generating a Sprox form with Turbogears 2.1 and trying to display it in a Mako template. Here is my code:
To define the form:
class NewUserForm(AddRecordForm):
__model__ = User
newuserform = NewUserForm(DBSession)
The controller definition that assigns the form and calls the template:
@expose('limelight.modules.users.templates.register')
def register(self, **kw):
tmpl_context.register_form = newuserform
return dict(value=kw)
And the relevant template code:
${tmpl_context.register_form(value=value)}
The problem is the HTML code is displayed as plain text on the page, not rendered HTML.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
想通了。我必须通过 'n' mako 过滤器传递变量,以删除 mako 应用于生成的 html 的任何自动过滤器。所以:
${tmpl_context.register_form(value=value) | n}
Figured it out. I have to pass the variable through the the 'n' mako filter to remove any automatic filters mako applies to the html generated. So:
${tmpl_context.register_form(value=value) | n}