<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
Hello world
<br>
{{ data.name }}
<br>
{{ data.age }}
<br>
{{ data.list[1] }}
<br>
{{ "hello_world" | upper }}
</body>
</html>
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/index")
def index():
data = {
'name': "张三",
"age": 18,
'list': [123123,41,123]
}
return render_template("index2.html", data=data)
if __name__ == '__main__':
app.run()
就可以看到大写的内容
更多转换文档请参考
Template Designer Documentation --- Jinja Documentation (2.10.x)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
Hello world
<br>
{{ data.name }}
<br>
{{ data.age }}
<br>
{{ data.list[1] }}
<br>
{{ "hello_world" | upper | replace('HELLO','HI') }}
</body>
</html>