开发者

how to make my method running on the template of google-app-engine

the model is :

class someModel(db.Model):
    name = db.StringProperty()

    def name_is_sss(self):
        return self.name=='sss'

the view is :

    a=someModel()
    a.name='sss'
    path = os.path.join(os.path.dirname(__file__), os.path.join('templates', 'blog/a.html'))
    self.response.out.write(template.render(path, {'a':a}))

and the html is :

{{ a.name_is_sss }}

the page shows :

True 

so i want to make it more useful, and like this:

the model:

class someModel(db.Model):
    name = db.Strin开发者_如何学PythongProperty()

    def name_is_x(self,x):
        return self.name==x

the html is :

{% a.name_is_x 'www'%}

or

{{ a.name_is_x 'www'}}

but the error is :

TemplateSyntaxError: Invalid block tag: 'a.name_is_x'

or

TemplateSyntaxError: Could not parse the remainder:  'www'

so how to make my method running

thanks


Did you try this already?

{{ a.name_is_x('www') }}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜