djangosnippets.org: Latest snippets posted by aquilahttps://djangosnippets.org/users/aquila/2007-03-30T20:19:54.168050-05:00aquila{% exec %} template tag
2007-03-30T20:19:54.168050-05:00aquilahttps://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