1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | from django import template
register = template.Library()
@register.tag(name='eval')
def do_eval(parser, token):
"Usage: {% eval %}1 + 1{% endeval %}"
nodelist = parser.parse(('endeval',))
class EvalNode(template.Node):
def render(self, context):
return eval(nodelist.render(context))
parser.delete_first_token()
return EvalNode()
|
More like this
- FloatField with safe expression parsing by joelegner 1 year, 11 months ago
- math tag by itchyfingrs 9 months, 1 week ago
- A templatetag to insert the output of another view (or local URL) by jamesgpearce 2 years, 7 months ago
- Automatic Paragraphs by Mirrorball 4 years, 6 months ago
- Template tag "ifregex" and "ifnotregex" by arthurfurlan 2 years, 8 months ago
Comments
Some specialists argue that personal loans aid people to live the way they want, because they are able to feel free to buy needed stuff. Moreover, some banks present auto loan for young and old people.
#