使用Mako的Turbogears的Sprox表单仅显示纯文本 [英] Sprox form with Turbogears, using Mako, only displays plain text

查看:67
本文介绍了使用Mako的Turbogears的Sprox表单仅显示纯文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Turbogears 2.1生成Sprox表单,并尝试将其显示在Mako模板中.这是我的代码:

I'm generating a Sprox form with Turbogears 2.1 and trying to display it in a Mako template. Here is my code:

定义形式:

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)  

以及相关的模板代码:

${tmpl_context.register_form(value=value)}

问题是HTML代码在页面上显示为纯文本,而不是呈现的HTML.

The problem is the HTML code is displayed as plain text on the page, not rendered HTML.

推荐答案

弄清楚了.我必须通过'n'mako过滤器传递变量,以删除mako应用于生成的html的所有自动过滤器.所以:

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}

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

这篇关于使用Mako的Turbogears的Sprox表单仅显示纯文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆