playing wiht Jinja
parent
a533819573
commit
9133512ec1
@ -0,0 +1,15 @@
|
||||
import os
|
||||
from jinja2 import Template
|
||||
|
||||
wd = os.path.dirname(os.path.abspath(__file__)) # working directory
|
||||
|
||||
# read template files
|
||||
with open(os.path.join(wd, '../templates/scatch.html')) as document_html:
|
||||
template = Template(document_html.read())
|
||||
|
||||
imgs_list = ['images/01.jpg', 'images/02.jpg', 'images/03.jpg']
|
||||
|
||||
template_render = template.render(title=':) Hello Sandra',
|
||||
imgs=imgs_list
|
||||
)
|
||||
print(template_render)
|
@ -0,0 +1,13 @@
|
||||
<h1>{{ title|upper }}</h1>
|
||||
|
||||
<div class="row">
|
||||
<div class="column">
|
||||
|
||||
{% for img in imgs %}
|
||||
<img src="{{img}}" style="width:100%">
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{imgs}}
|
Loading…
Reference in New Issue