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

Posted by zjm1126 on Stack Overflow See other posts from Stack Overflow or by zjm1126
Published on 2010-05-16T03:36:28Z Indexed on 2010/05/16 3:40 UTC
Read the original article Hit count: 281

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.StringProperty()

    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

© Stack Overflow or respective owner

Related posts about google-app-engine

Related posts about python