Skip to content
Myr

Merge pull request #1010 from dvamin/master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by GitHub · parents 67e2542, 4965fac · Browse files · 2 files+3 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • docs: Python3-ize the examples

Diff stats

2 files+3 added−4 removed

  • other:+3 added−4 removed

2 files+3 added−4 removed

modified:docs/api.rst+2 added-2 removed
44 unmodified lines
45 template = env.get_template('mytemplate.html')4647To render it with some variables, just call the :meth:`render` method::4849 print template.render(the='variables', go='here')49 print(template.render(the='variables', go='here'))5051Using a template loader rather than passing strings to :class:`Template`52or :meth:`Environment.from_string` has multiple advantages. Besides being53a lot easier to use it also enables template inheritance.
779 unmodified lines
833834 def is_prime(n):835 if n == 2:836 return True837 for i in xrange(2, int(math.ceil(math.sqrt(n))) + 1):837 for i in range(2, int(math.ceil(math.sqrt(n))) + 1):838 if n % i == 0:839 return False840 return True841
91 unmodified lines
modified:docs/templates.rst+1 added-2 removed
570 unmodified lines
571As variables in templates retain their object properties, it is possible to572iterate over containers like `dict`::573574 <dl>575 {% for key, value in my_dict.iteritems() %}575 {% for key, value in my_dict.items() %}576 <dt>{{ key|e }}</dt>577 <dd>{{ value|e }}</dd>578 {% endfor %}579 </dl>
615 unmodified lines
11951196/1197 Divide two numbers. The return value will be a floating point number.1198 ``{{ 1 / 2 }}`` is ``{{ 0.5 }}``.1199 (Just like ``from __future__ import division``.)11991200//1201 Divide two numbers and return the truncated integer result.1202 ``{{ 20 // 7 }}`` is ``2``.
466 unmodified lines