My Hackpact entries here: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "==25 09 2019== ==26 09 2019==")
 
Line 1: Line 1:
==25 09 2019==
==25 09 2019==
try to use Jinja to generate repetitive tags and id in html page.
<source lang="python">
from jinja2 import Template
images_html=Template('''<img>
{% for image in images %}
<img class="image" id=images_{{ image }}></img>
{% endfor %}
''')
names = ["1", "2", "3", "4", "5", "6", "7"]
images_list=images_html.render(images=names)
print(images_list)
</source>
==26 09 2019==
==26 09 2019==

Revision as of 20:17, 25 September 2019

25 09 2019

try to use Jinja to generate repetitive tags and id in html page.

from jinja2 import Template

images_html=Template('''<img>
	{% for image in images %}
	<img class="image" id=images_{{ image }}></img>
	{% endfor %}
	
''')

names = ["1", "2", "3", "4", "5", "6", "7"]

images_list=images_html.render(images=names)
print(images_list)

26 09 2019