+from __future__ import print_function
from jinja2 import Environment
env = Environment(line_statement_prefix="#", variable_start_string="${", variable_end_string="}")
-print env.from_string("""\
+print(env.from_string("""\
<ul>
# for item in range(10)
<li class="${loop.cycle('odd', 'even')}">${item}</li>
# endfor
</ul>\
-""").render()
+""").render())
+from __future__ import print_function
from jinja2 import Environment
from jinja2.loaders import FileSystemLoader
env = Environment(loader=FileSystemLoader('templates'))
tmpl = env.get_template('broken.html')
-print tmpl.render(seq=[3, 2, 4, 5, 3, 2, 0, 2, 1])
+print(tmpl.render(seq=[3, 2, 4, 5, 3, 2, 0, 2, 1]))
+from __future__ import print_function
from jinja2 import Environment
from jinja2.loaders import DictLoader
}))
-print env.get_template('c').render()
+print(env.get_template('c').render())
+from __future__ import print_function
from jinja2 import Environment
from jinja2.loaders import DictLoader
+from __future__ import print_function
from jinja2 import Environment
+from __future__ import print_function
from jinja2 import Environment
tmpl = Environment().from_string("""\
+from __future__ import print_function
from jinja2 import Environment
env = Environment(extensions=['jinja2.ext.i18n'])
'%(count)s user': '%(count)d Benutzer',
'%(count)s users': '%(count)d Benutzer'
}[n == 1 and s or p]
-print env.from_string("""\
+print(env.from_string("""\
{% trans %}Hello {{ user }}!{% endtrans %}
{% trans count=users|count %}{{ count }} user{% pluralize %}{{ count }} users{% endtrans %}
-""").render(user="someone", users=[1, 2, 3])
+""").render(user="someone", users=[1, 2, 3]))
+from __future__ import print_function
try:
from cProfile import Profile
except ImportError:
variable_start_string="${",
variable_end_string="}"
).from_string(source)
-print jinja_template.environment.compile(source, raw=True)
+print(jinja_template.environment.compile(source, raw=True))
p = Profile()
:copyright: (c) 2009 by the Jinja Team.
:license: BSD.
"""
+from __future__ import print_function
import sys
from os.path import join, dirname, abspath
try:
sys.stdout.write('\r %-20s%.4f seconds\n' % (test, t.timeit(number=200) / 200))
if '-p' in sys.argv:
- print 'Jinja profile'
+ print('Jinja profile')
p = Profile()
p.runcall(test_jinja)
stats = Stats(p)
:copyright: (c) 2009 by the Jinja Team.
:license: BSD.
"""
+from __future__ import print_function
import re
import os
import sys
if callback is None:
def callback(template):
- print template
+ print(template)
for directory in settings.TEMPLATE_DIRS:
for dirname, _, files in os.walk(directory):
if node is not None and hasattr(node, 'source'):
filename, lineno = self.get_location(*node.source)
message = '[%s:%d] %s' % (filename, lineno, message)
- print >> self.error_stream, message
+ print(message, file=self.error_stream)
def translate_variable_name(self, var):
"""Performs variable name translation."""
"""Load a template."""
try:
return get_env().get_template(template_name, globals=globals)
- except TemplateNotFound, e:
+ except TemplateNotFound as e:
raise TemplateDoesNotExist(str(e))
:copyright: Copyright 2010 by Armin Ronacher.
:license: BSD.
"""
+from __future__ import print_function
import sys
import jinja2
from werkzeug import script