ํ์ผ์ด๋ฆ : 010_template_engine\template\base.html
<!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>
<p>๋ฉ๋ด</p>
{#
๋ณดํต์ block style, block content, block script๋ก ๋๋ ์์ฑ
#}
{% block content %}
{% endblock %}<p>ํธํฐ</p>
</body>
</html>
ํ์ผ์ด๋ฆ : 010_template_engine\template\test1.html
<!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>
<h1>hello world</h1>
<p>{{ name }}</p>
<p>{{ age }}</p>
</body>
</html>
ํ์ผ์ด๋ฆ : 010_template_engine\template\test2.html
<!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>
<h1>hello world</h1>
{% for i in ์๊ธ %}
<h1>{{ i.์ํ๋ช
}}</h1>
<p>{{ i.๊ณ์ข๋ฒํธ }}</p>
<p>{{ i.๊ธ์ก }}</p>
{% endfor %}{% for i, j in ์ต๋์ฐ๋ %}
<h1>{{ i }}, {{ j }}</h1>
{% endfor %}
</body>
</html>
ํ์ผ์ด๋ฆ : 010_template_engine\template\test3.html
<!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>
{# ์ฃผ์, ์กฐ๊ฑด๋ฌธ, ๋ณ์, ํํฐ, ์ฌ์ ์์ ๋ ฌ #}
<h1>hello world</h1>
{#
Comparisons :
==
===
!=
!==
>
>=
<
<= Logic :
and
or
not
#}
{% for i in ์๊ธ %}
{% if i.๊ธ์ก <= 100 %}
<h1 style="color:red;">{{ i.์ํ๋ช
}}</h1>
<p>{{ i.๊ณ์ข๋ฒํธ }}</p>
<p>{{ i.๊ธ์ก }}</p>
{% elif i.๊ธ์ก <= 200 %}
<h1 style="color:green;">{{ i.์ํ๋ช
}}</h1>
<p>{{ i.๊ณ์ข๋ฒํธ }}</p>
<p>{{ i.๊ธ์ก }}</p>
{% else %}
<h1 style="color:blue;">{{ i.์ํ๋ช
}}</h1>
<p>{{ i.๊ณ์ข๋ฒํธ }}</p>
<p>{{ i.๊ธ์ก }}</p>
{% endif %}
{% endfor %}
<hr>
{% set x = 10 %}
{% set y = 10 %}
{{ x + y }}
{#
Addition: +
Subtraction: -
Division: /
Division and integer truncation: //
Division remainder: %
Multiplication: *
Power: **
#}
<hr>
{# ์ฐ๋ฆฌ๊ฐ true๋ก ์ค์ ํด Autoescaping์ด ๋ฉ๋๋ค. #}
{{ text }}
{{ text | safe }}
{{ text | escape }}
{{ -x | abs }}
<hr>
<p>์๋์ ๊ฐ์ ๊ฒ ๋ง๊ณ ๋ join, reverse ๊ฐ์ ๊ฒ์ ์ง์ํฉ๋๋ค. ๊ฒ์ํ์ ๊ฒ์๋ฌผ ์ ๋ ฌํ๊ธฐ ์ข๊ฒ ์ฃ .</p>
{% set items = {
'ae': 1,
'ad': 2,
'ac': 3,
'ba': 4,
'bf': 5,
'bb': 6
} %}
{% for item in items | dictsort %}
{{ item }}
{% endfor %}
</body>
</html>
ํ์ผ์ด๋ฆ : 010_template_engine\template\test4.html
{% extends 'base.html' %}
{% block content %}
<p>๋ด์ฉ</p>
<p>๋ด์ฉ</p>
<p>๋ด์ฉ</p>
<p>๋ด์ฉ</p>
<p>๋ด์ฉ</p>
<p>๋ด์ฉ</p>
{% endblock %}