jinja2 latest version code example
Example 1: jinja2 include template
{% include "to_be_included.html" with context %}
Example 2: jinja2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class = "container">
<h1>
Hi my name is {{ name }}
</h1>
</div>
</body>
</html>
Example 3: length jinja2
list|length
Example 4: jinja2
import flask
from flask import Flask , render_templates
app = Flask(__name__)
@app.route("/")
def hi():
name = "Your Name"
return render_templates(index.html , name = name)