playing wiht Jinja

populat_orgs
Castro0o 5 years ago
parent a533819573
commit 9133512ec1

@ -96,6 +96,11 @@ for answer in site.ask(query):
pagetext_html = pandoc(pwd=wd, content=pagetext, format_in='mediawiki', format_out='html') pagetext_html = pandoc(pwd=wd, content=pagetext, format_in='mediawiki', format_out='html')
img_local = os.path.join(imgdir, img_info.get('filename')) img_local = os.path.join(imgdir, img_info.get('filename'))
# Todo: Create list of all images from document
# TODO: join document_part + document
# TODO: look into the template structure of images : columns and rows
# RENDER document part # RENDER document part
document_part_html = document_part_template.render( document_part_html = document_part_template.render(
printout_dict=printout_dict, printout_dict=printout_dict,

@ -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…
Cancel
Save