Sprox 形式与 Turbogears,使用 Mako,仅显示纯文本

发布于 2024-08-15 07:38:47 字数 542 浏览 1 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉宸 2024-08-22 07:38:47

想通了。我必须通过 '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}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文