In django we can do this:
views.py :
def A(request):
context = {test : 'test'}
return render_to_response('index.html', context , context_instance = RequestContext(request))
def B(request):
context = {}
return render_to_response('index.html', context , context_instance = RequestContext(request))
index.html:
{% if test %}
{{ test }}
{% endif %}
And our rendering of the template is error-free, even if I use method Bit where the variable 'test'does not exist, but I can still put it in the template.
I want to do the same with pylons + mako, in the controller:
foo.py
def A(self):
c.test = 'test'
return render('index.html')
def B(self):
return render('index.html')
index.html :
% if c.test:
${'c.test'}
% endif
In Django I can do this, but in Pylons I get an error message, is there a way to check if exter exists 'c.test'or not?
error: AttributeError: object 'ContextObj' does not have attribute 'test'
source
share