File indexing completed on 2024-05-12 04:02:11

0001 {# Basic extension of a common file #}
0002 {% extends "base_file.html" %}
0003 
0004 {% block title %}{{ section.title }}{% endblock %}
0005 
0006 {% block content %}
0007 <h1>{{ section.title }}</h1>
0008 
0009 {# For loop example #}
0010 
0011 {% for item in item_list %}
0012 <h2>
0013   <a href="{{ item.get_absolute_url }}">
0014     {{ item.text }}
0015     {{ item.other_text|upper }}
0016   </a>
0017 </h2>
0018 <p>{{ story.longer_text|truncatewords:"100" }}</p>
0019 {% endfor %}
0020 {% endblock %}
0021 
0022 
0023 {# For loop example with specific content if empty #}
0024 
0025 {% for item in other_list %}
0026 <h2>
0027     {{ item.text }}
0028 </h2>
0029 {% else %}
0030 <h2>
0031     This list is empty
0032 </h2>
0033 {% endfor %}
0034 {% endblock %}
0035 
0036 
0037 {# if example #}
0038 
0039 {% if item_list %}
0040     Number of items: {{ item_list|length }}
0041 {% elif some_condition %}
0042     Show this text
0043 {% else %}
0044     Nothing to process
0045 {% endif %}
0046 
0047 {# This is a comment #} hello comment
0048 
0049 
0050 {# Translation example #}
0051 
0052 {% translate "Title" as title %}
0053 {% block content %}{{ title }}{% endblock %}
0054 
0055 
0056 {# Auto-escaping #}
0057 
0058 {% autoescape off %}
0059     Hello {{ name }}
0060 {% endautoescape %}
0061 
0062 
0063 {# Loading custom tags/libraries #}
0064 
0065 {% load humanize %}