티스토리 뷰

Daliy Note

Jinja

Raziel 2021. 7. 25. 20:02

Docs #

# Jinja2 Librury: Flask Template Engine  
# Types
String, XML, HTML, JSON, Image, Video, etc
# example
{% extends "application.html" %}
{% block body %}
	<ul>
		{% for song in songs %}
			<li><a href="{{song.url}}"> {{song.title}} </a></li>
		{% endfor %}
	</ul>
{% endblock %}
render_template("xx.html", username="Jade")
{# comment #}
from flask import render_template
@app.route("/")
def tmpl():
    return render_template("index.html")
# ./templates/index.html
<pre>
ttt 한글
{% if True  %}
    TTT
{% endif %}qqq
</pre>
# trim_blocks app config
app.jinja_env.trim_blocks = True

 

'Daliy Note' 카테고리의 다른 글

#SC3  (0) 2021.07.29
Postman  (0) 2021.07.27
Flask - hub  (0) 2021.07.23
Section3 - Review  (0) 2021.07.22
Elice  (0) 2021.07.21
댓글