non définie dans le contrôleur, je définis 2 Méthode:Pylônes Mako variables
foobar.py:
class foo(self):
c.help_text = 'help'
return render('/index.html')
class bar(self):
return render('/index.html')
index.html:
${c.help_text}
Cela me donne une erreur ==> AttributeError: l'objet 'ContextObj' n'a pas d'attribut 'help_text'
Après avoir lu quelques documents mako, j'essaie:
% if c.help_text is UNDEFINED:
foo
% else:
${c.help_text}
% endif
Cela me donne aussi une erreur. Puis dans mon development.ini, je mets:
mako.strict_undefined = false
après
[app:main]
Cela me donne toujours une erreur ==> AttributeError: objet 'ContextObj' n'a pas d'attribut 'help_text'
voir cette question: http://stackoverflow.com/questions/12006720/pylons-mako-how-to-check-if-variable-exist-or-not –