开发者

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

开发者 https://www.devze.com 2022-12-14 01:44 出处:网络
I\'m generating a Sprox form with Turbogears 2.1 and trying to display it in a Mako template. Here is my code:

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.mo开发者_StackOverflowdules.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.


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}

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号