Sprox form with Turbogears, using Mako, only displays plain text

余生长醉 提交于 2019-12-11 03:44:48

问题


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.


回答1:


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}



来源:https://stackoverflow.com/questions/1919833/sprox-form-with-turbogears-using-mako-only-displays-plain-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!