djangosnippets.org: Latest snippets tagged with 'exec'http://djangosnippets.org/tags/exec/2009-11-27T20:17:23.588101-06:00{% eval %} templatetag-evaluate expressions
2009-11-27T20:17:23.588101-06:00divermanhttp://djangosnippets.org/snippets/1820/<p>This templatetag evaluates Python expressions including built-in functions, lambda functions etc... Use with caution.</p>
Freely redistributable{% exec %} template tag
2007-03-30T20:19:54.168050-05:00aquilahttp://djangosnippets.org/snippets/146/<p>usage:
1、
{% exec %}
class A:
def <strong>call</strong>(self):
print "I Love Python!";
{% endexec %}</p>
<p>2、
{% exec from django.conf import settings; %}</p>
<p>3、
{% exec %}
try:
html = ''
if book:
html = book.TransToHtml().encode('utf8');
except Exception,msg:
html = str(msg);</p>
<p>if settings.TEMPLATE_DEBUG:
open('c:/index.html','wb').write(html);</p>
<p>{% endexec %}</p>
Freely redistributable