SpecialistOff.NET / Вопросы / Статьи / Фрагменты кода / Резюме / Метки / Помощь / Файлы
Список вопросов Печать| RemiZOffAlex Создано: 2018-10-21 17:14:08.078838 Обновлено: 2018-10-21 17:14:08.078838 |
|---|
from jinja2 import Environment, DictLoader
html = '''<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
{% include 'inc.html' %}
</body>
</html>
'''
html2 = '''
{% for item in range(5) %}
Hello {{ name }}!
{% endfor %}
'''
env = Environment(loader=DictLoader({'index.html': html, 'inc.html': html2}))
template = env.get_template('index.html')
print(template.render(name=u'Петя'))
|