Немного документации

This commit is contained in:
Федор Подлеснов 2015-12-11 11:55:34 +03:00
parent bb834a0f2d
commit 999fe634de
3 changed files with 67 additions and 5 deletions

61
readme.md Normal file
View file

@ -0,0 +1,61 @@
#Простой шаблонизатор
#Переменные
Для переменной name=Андрей шаблон
```html
<b>Hello, {{ name }}</div>
```
преобразуется в
```html
<b>Hello, Андрей</div>
```
```html
<b>Hello, {{! name }} </div>
```
преобразуется в
```html
<b>Hello, <!-- Андрей --></div>
```
#Циклы
```html
<ul>
{% for user in users %}
<li>Hello, {{ user.name }}</li>
{% endfor %}
</ul>
```
#Условия
```html
<ul>
{% for user in users %}
{% if user.is_russian %}
<li>Привет, {{ user.name }}</li>
{% else %}
<li>Hello, {{ user.name }}</li>
{% endif %}
{% endfor %}
</ul>
```
#Макрос
```html
{% macro hello(user) %}
{% if user.is_russian %}
<li>Привет, {{ user.name }}</li>
{% else %}
<li>Hello, {{ user.name }}</li>
{% endif %}
{% endmacro %}
<ul>
{% for user in users %}
{% hello(user) %}
{% endfor %}
</ul>
```