template-engine

Jinja2 round filter not rounding

Jinja2 round filter not rounding Question: I have the following code in my template: data: [{% for deet in deets %} {{ deet.value*100|round(1) }}{% if not loop.last %},{% endif %} {% endfor %}] I am expecting data rounded to 1 decimal place. However, when I view the page or source, this is the output I’m …

Total answers: 5

Jinja 2 safe keyword

Jinja 2 safe keyword Question: I have a little problem understanding what an expression like {{ something.render() | safe }} does . From what I have seen, without the safe keyword it outputs the entire html document, not just the true content. What I would like to know, is what it actually does, how it …

Total answers: 5

advanced string formatting vs template strings

advanced string formatting vs template strings Question: I was wondering if there is a advantage of using template strings instead of the new advanced string formatting? Asked By: P3trus || Source Answers: Templates are meant to be simpler than the the usual string formatting, at the cost of expressiveness. The rationale of PEP 292 compares …

Total answers: 6

Mako or Jinja2?

Mako or Jinja2? Question: I didn’t find a good comparison of jinja2 and Mako. What would you use for what tasks ? I personnaly was satisfied by mako (in a pylons web app context) but am curious to know if jinja2 has some nice features/improvements that mako doesn’t ? -or maybe downsides ?- Asked By: …

Total answers: 2

What is the fastest template system for Python?

What is the fastest template system for Python? Question: Jinja2 and Mako are both apparently pretty fast. How do these compare to (the less featured but probably good enough for what I’m doing) string.Template ? Asked By: Josh Gibson || Source Answers: From the jinja2 docs, it seems that string.Template is the fastest if that’s …

Total answers: 5

How do I use Django templates without the rest of Django?

How do I use Django templates without the rest of Django? Question: I want to use the Django template engine in my (Python) code, but I’m not building a Django-based web site. How do I use it without having a settings.py file (and others) and having to set the DJANGO_SETTINGS_MODULE environment variable? If I run …

Total answers: 15