66 lines
1.0 KiB
HTML
66 lines
1.0 KiB
HTML
{# Basic extension of a common file #}
|
|
{% extends "base_file.html" %}
|
|
|
|
{% block title %}{{ section.title }}{% endblock %}
|
|
|
|
{% block content %}
|
|
<h1>{{ section.title }}</h1>
|
|
|
|
{# For loop example #}
|
|
|
|
{% for item in item_list %}
|
|
<h2>
|
|
<a href="{{ item.get_absolute_url }}">
|
|
{{ item.text }}
|
|
{{ item.other_text|upper }}
|
|
</a>
|
|
</h2>
|
|
<p>{{ story.longer_text|truncatewords:"100" }}</p>
|
|
{% endfor %}
|
|
{% endblock %}
|
|
|
|
|
|
{# For loop example with specific content if empty #}
|
|
|
|
{% for item in other_list %}
|
|
<h2>
|
|
{{ item.text }}
|
|
</h2>
|
|
{% else %}
|
|
<h2>
|
|
This list is empty
|
|
</h2>
|
|
{% endfor %}
|
|
{% endblock %}
|
|
|
|
|
|
{# if example #}
|
|
|
|
{% if item_list %}
|
|
Number of items: {{ item_list|length }}
|
|
{% elif some_condition %}
|
|
Show this text
|
|
{% else %}
|
|
Nothing to process
|
|
{% endif %}
|
|
|
|
{# This is a comment #} hello comment
|
|
|
|
|
|
{# Translation example #}
|
|
|
|
{% translate "Title" as title %}
|
|
{% block content %}{{ title }}{% endblock %}
|
|
|
|
|
|
{# Auto-escaping #}
|
|
|
|
{% autoescape off %}
|
|
Hello {{ name }}
|
|
{% endautoescape %}
|
|
|
|
|
|
{# Loading custom tags/libraries #}
|
|
|
|
{% load humanize %}
|