【问题标题】:Sprox form with Turbogears, using Mako, only displays plain text带有 Turbogears 的 Sprox 表单,使用 Mako,仅显示纯文本
【发布时间】:2010-12-27 13:12:36
【问题描述】:

我正在使用 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。

【问题讨论】:

    标签: python forms mako turbogears sprox


    【解决方案1】:

    想通了。我必须通过 'n' mako 过滤器传递变量以删除任何自动过滤器 mako 适用于生成的 html。所以:

    ${tmpl_context.register_form(value=value) | n}

    【讨论】:

      猜你喜欢
      • 2017-01-11
      • 2021-02-09
      • 2011-02-14
      • 2015-04-29
      • 2016-07-25
      • 2022-10-05
      • 1970-01-01
      • 1970-01-01
      • 2013-02-17
      相关资源
      最近更新 更多