Close HTML tags in template examples.

This commit is contained in:
A. Jesse Jiryu Davis 2016-01-10 15:36:42 -05:00
parent 45014ce289
commit f75fc6fc80
43 changed files with 47 additions and 45 deletions

View File

@ -20,7 +20,7 @@ differs between Python and templates. In templates you have to use the
<ul> <ul>
{% for item in this.children.filter( {% for item in this.children.filter(
(F.type == 'hotel').and(F.stars >= 3)) %} (F.type == 'hotel').and(F.stars >= 3)) %}
<li>{{ item.name }}: {{ item.stars }} stars <li>{{ item.name }}: {{ item.stars }} stars</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -19,7 +19,7 @@ contained in another string or a item can be contained within a list.
<h3>Projects Tagged 'amazing'</h3> <h3>Projects Tagged 'amazing'</h3>
<ul> <ul>
{% for item in this.children.filter(F.tags.contains('amazing')) %} {% for item in this.children.filter(F.tags.contains('amazing')) %}
<li>{{ item.name }} <li>{{ item.name }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -18,7 +18,7 @@ see [endswith :ref](../endswith/).
```html+jinja ```html+jinja
<ul> <ul>
{% for item in this.children.filter(F.name.endswith_cs('House')) %} {% for item in this.children.filter(F.name.endswith_cs('House')) %}
<li>{{ item.name }} <li>{{ item.name }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -18,7 +18,7 @@ see [endswith_cs :ref](../endswith-cs/).
```html+jinja ```html+jinja
<ul> <ul>
{% for item in this.children.filter(F.name.endswith('house')) %} {% for item in this.children.filter(F.name.endswith('house')) %}
<li>{{ item.name }} <li>{{ item.name }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -15,7 +15,7 @@ Typically it compares if a value matches a specific value exactly:
<h2>Our Houses</h2> <h2>Our Houses</h2>
<ul> <ul>
{% for project in this.children.filter(F.type == 'house') %} {% for project in this.children.filter(F.type == 'house') %}
<li>{{ project.name }} <li>{{ project.name }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -16,7 +16,7 @@ or equal to it. This behavior works best with [integers
<h3>3 or more Stars</h3> <h3>3 or more Stars</h3>
<ul> <ul>
{% for item in this.children.filter(F.stars >= 3) %} {% for item in this.children.filter(F.stars >= 3) %}
<li>{{ item.name }}: {{ item.stars }} stars <li>{{ item.name }}: {{ item.stars }} stars</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -16,7 +16,7 @@ or [floats :ref](../../types/float/).
<h3>Well Rated Items</h3> <h3>Well Rated Items</h3>
<ul> <ul>
{% for item in this.children.filter(F.stars > 3) %} {% for item in this.children.filter(F.stars > 3) %}
<li>{{ item.name }}: {{ item.stars }} stars <li>{{ item.name }}: {{ item.stars }} stars</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -16,7 +16,7 @@ or equal to it. This behavior works best with [integers
<h3>Projects From Before Including 2000</h3> <h3>Projects From Before Including 2000</h3>
<ul> <ul>
{% for item in this.children.filter(F.year <= 2000) %} {% for item in this.children.filter(F.year <= 2000) %}
<li>{{ item.name }} ({{ item.year }}) <li>{{ item.name }} ({{ item.year }})</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -16,7 +16,7 @@ or equal to it. This behavior works best with [integers
<h3>Projects From Before 2000</h3> <h3>Projects From Before 2000</h3>
<ul> <ul>
{% for item in this.children.filter(F.year < 2000) %} {% for item in this.children.filter(F.year < 2000) %}
<li>{{ item.name }} ({{ item.year }}) <li>{{ item.name }} ({{ item.year }})</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -15,7 +15,7 @@ by doing a exact comparision:
<h2>Everything Other Than Houses</h2> <h2>Everything Other Than Houses</h2>
<ul> <ul>
{% for project in this.children.filter(F.type != 'house') %} {% for project in this.children.filter(F.type != 'house') %}
<li>{{ project.name }} <li>{{ project.name }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -20,7 +20,7 @@ differs between Python and templates. In templates you have to use the
<ul> <ul>
{% for item in this.children.filter( {% for item in this.children.filter(
(F.type == 'hotel').or(F.type == 'apartment')) %} (F.type == 'hotel').or(F.type == 'apartment')) %}
<li>{{ item.name }} ({{ item.type}}) <li>{{ item.name }} ({{ item.type}})</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -19,7 +19,7 @@ see [startswith :ref](../startswith/).
<h1>A</h1> <h1>A</h1>
<ul> <ul>
{% for item in this.children.filter(F.name.startswith_cs('A')) %} {% for item in this.children.filter(F.name.startswith_cs('A')) %}
<li>{{ item.name }} <li>{{ item.name }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -19,7 +19,7 @@ see [startswith_cs :ref](../startswith-cs/).
<h1>A</h1> <h1>A</h1>
<ul> <ul>
{% for item in this.children.filter(F.name.startswith('a')) %} {% for item in this.children.filter(F.name.startswith('a')) %}
<li>{{ item.name }} <li>{{ item.name }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -22,7 +22,7 @@ Accessing an attributes creates an [Expression :ref](../expression/).
```html+jinja ```html+jinja
<ul> <ul>
{% for item in this.children.filter(F.status == 'published') %} {% for item in this.children.filter(F.status == 'published') %}
<li>{{ item.title }} <li>{{ item.title }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -24,6 +24,6 @@ source objects is that they are always visible.
```html+jinja ```html+jinja
{% set downloads = site.get('/downloads') %} {% set downloads = site.get('/downloads') %}
{% if downloads.is_hidden %} {% if downloads.is_hidden %}
<p>Downloads are currently unavailable <p>Downloads are currently unavailable</p>
{% endif %} {% endif %}
``` ```

View File

@ -14,5 +14,5 @@ where this property can be used to discover the associated parent object.
## Example ## Example
```html+jinja ```html+jinja
<p>My parent is: {{ this.parent.path }} <p>My parent is: {{ this.parent.path }}</p>
``` ```

View File

@ -33,7 +33,7 @@ Here another example that loads the current page but in another language:
```html+jinja ```html+jinja
{% set other_lang = site.get(this._path, alt='ru') %} {% set other_lang = site.get(this._path, alt='ru') %}
<p>This page in Russian: {{ other_lang.title }} <p>This page in Russian: {{ other_lang.title }}</p>
``` ```
## Virtual Paths ## Virtual Paths

View File

@ -18,7 +18,7 @@ and will also include hidden pages.
```html+jinja ```html+jinja
<ul> <ul>
{% for project in site.query('/projects') %} {% for project in site.query('/projects') %}
<li>{{ project.name }}: {{ project.year }} <li>{{ project.name }}: {{ project.year }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -18,7 +18,7 @@ handy.
{% if items %} {% if items %}
<ul> <ul>
{% for item in items %} {% for item in items %}
<li>{{ item.name }} <li>{{ item.name }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}

View File

@ -22,7 +22,7 @@ Here a basic example of how to filter something in a template:
```html+jinja ```html+jinja
<ul> <ul>
{% for item in this.children.filter(F.status == 'published') %} {% for item in this.children.filter(F.status == 'published') %}
<li>{{ item.title }} <li>{{ item.title }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -12,5 +12,5 @@ This is a simple way to count the total number of items a query matches.
```html+jinja ```html+jinja
{% set project_count = site.query('/projects').count() %} {% set project_count = site.query('/projects').count() %}
<p>We built {{ project_count }} projects. <p>We built {{ project_count }} projects.</p>
``` ```

View File

@ -22,7 +22,7 @@ Here a basic example of how to filter something in a template:
```html+jinja ```html+jinja
<ul> <ul>
{% for item in this.children.filter(F.status == 'published') %} {% for item in this.children.filter(F.status == 'published') %}
<li>{{ item.title }} <li>{{ item.title }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -15,6 +15,6 @@ query. If no such record can be produced, `None` is returned.
{% first_visible = this.children.first() %} {% first_visible = this.children.first() %}
{% if first_visible %} {% if first_visible %}
<h2>Explore More ...</h2> <h2>Explore More ...</h2>
<p>{{ first_visible.title }} <p>{{ first_visible.title }}</p>
{% endif %} {% endif %}
``` ```

View File

@ -18,5 +18,5 @@ requested page number from the query for pagination.
```html+jinja ```html+jinja
{% set p1 = this.children.get('project-1') %} {% set p1 = this.children.get('project-1') %}
<h2>{{ p1.name }}</h2> <h2>{{ p1.name }}</h2>
<p>Our favorite! <p>Our favorite!</p>
``` ```

View File

@ -24,7 +24,7 @@ Here a basic example of how to filter something in a template:
```html+jinja ```html+jinja
<ul> <ul>
{% for item in this.children.include_hidden(true) %} {% for item in this.children.include_hidden(true) %}
<li>{{ item.title }}{% if item.is_hidden %} (hidden){% endif %} <li>{{ item.title }}{% if item.is_hidden %} (hidden){% endif %}</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -25,7 +25,7 @@ Here a basic example of how to filter something in a template:
```html+jinja ```html+jinja
<ul> <ul>
{% for item in this.children.include_undiscoverable(true) %} {% for item in this.children.include_undiscoverable(true) %}
<li>{{ item.title }} <li>{{ item.title }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -17,7 +17,7 @@ of matching records.
<h3>Our Top 3</h3> <h3>Our Top 3</h3>
<ul> <ul>
{% for item in this.children.order_by('-rating').limit(3) %} {% for item in this.children.order_by('-rating').limit(3) %}
<li>{{ item.title }} <li>{{ item.title }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -23,7 +23,7 @@ order by year and within a year it will order by name.
```html+jinja ```html+jinja
<ul> <ul>
{% for project in this.children.order_by('-year', 'name') %} {% for project in this.children.order_by('-year', 'name') %}
<li>{{ project.year }}: {{ project.name }} <li>{{ project.year }}: {{ project.name }}</li>
{% endif %} {% endif %}
</ul> </ul>
``` ```

View File

@ -25,6 +25,7 @@ there is a good reason to use it.
<li> <li>
Items on the first page of {{ child.title }}: Items on the first page of {{ child.title }}:
{{ child.pagination.items.count() }} {{ child.pagination.items.count() }}
</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -27,7 +27,7 @@ via the [query :ref](../../pad/query/) method of the pad.
```html+jinja ```html+jinja
<ul> <ul>
{% for child in this.children %} {% for child in this.children %}
<li>{{ child.title }} <li>{{ child.title }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -25,6 +25,6 @@ attribute overlaps with your custom field, you need to access the fields
with the subscript syntax (`[]`): with the subscript syntax (`[]`):
```html+jinja ```html+jinja
<p>Built-in Path: {{ obj.path }} <p>Built-in Path: {{ obj.path }}</p>
<p>Path field: {{ obj['path'] }} <p>Path field: {{ obj['path'] }}</p>
``` ```

View File

@ -13,6 +13,6 @@ only implemented for attachments that are images.
```html+jinja ```html+jinja
{% for image in this.attachments.images %} {% for image in this.attachments.images %}
<p>{{ image._id }}: {{ image.format }} <p>{{ image._id }}: {{ image.format }}</p>
{% endfor %} {% endfor %}
``` ```

View File

@ -42,7 +42,7 @@ page:
```html+jinja ```html+jinja
<ul> <ul>
{% for child in this.pagination.items %} {% for child in this.pagination.items %}
<li>{{ child.title }} <li>{{ child.title }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -17,7 +17,7 @@ This field is most useful for filtering when operating on mixed collections.
```html+jinja ```html+jinja
<ul class="projects"> <ul class="projects">
{% for child in this.children.filter(F._model == 'project') %} {% for child in this.children.filter(F._model == 'project') %}
<li>{{ child.name }} <li>{{ child.name }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -23,5 +23,5 @@ type = date
## Template Usage ## Template Usage
```html+jinja ```html+jinja
<p>Published: {{ this.pub_date.strftime('%d/%m/%Y') }} <p>Published: {{ this.pub_date.strftime('%d/%m/%Y') }}</p>
``` ```

View File

@ -28,7 +28,7 @@ description = A list of things that would be good to buy
<h2>Shopping List</h2> <h2>Shopping List</h2>
<ul> <ul>
{% for item in this.things_to_buy %} {% for item in this.things_to_buy %}
<li>{{ item }} <li>{{ item }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
``` ```

View File

@ -31,11 +31,11 @@ more information see [CLDR Date/Time Symbols
## Examples ## Examples
```html+jinja ```html+jinja
<p>Date: {{ this.pub_date|dateformat('full') }} <p>Date: {{ this.pub_date|dateformat('full') }}</p>
``` ```
Or with custom CLDR format strings: Or with custom CLDR format strings:
```html+jinja ```html+jinja
<p>Date: {{ this.pub_date|dateformat('EEE, MMM d, ''yy') }} <p>Date: {{ this.pub_date|dateformat('EEE, MMM d, ''yy') }}</p>
``` ```

View File

@ -15,6 +15,6 @@ and [latlongformat :ref](../latlongformat/).
## Examples ## Examples
```html+jinja ```html+jinja
<p>Lat: {{ image.exif.latitude|latformat }} <p>Lat: {{ image.exif.latitude|latformat }}</p>
<p>Long: {{ image.exif.longitude|longformat }} <p>Long: {{ image.exif.longitude|longformat }}</p>
``` ```

View File

@ -15,5 +15,5 @@ in the format format degrees, minutes and seconds. See also [latformat
## Examples ## Examples
```html+jinja ```html+jinja
<p>Location: {{ image.exif.location|latlongformat }} <p>Location: {{ image.exif.location|latlongformat }}</p>
``` ```

View File

@ -15,6 +15,6 @@ and [latlongformat :ref](../latlongformat/).
## Examples ## Examples
```html+jinja ```html+jinja
<p>Lat: {{ image.exif.latitude|latformat }} <p>Lat: {{ image.exif.latitude|latformat }}</p>
<p>Long: {{ image.exif.longitude|longformat }} <p>Long: {{ image.exif.longitude|longformat }}</p>
``` ```

View File

@ -99,7 +99,7 @@ using their templates:
```html+jinja ```html+jinja
{% for blk in this.demo_flow.blocks %} {% for blk in this.demo_flow.blocks %}
{% if blk._flowblock == 'text' %} {% if blk._flowblock == 'text' %}
<p>{{ blk.text }} <p>{{ blk.text }}</p>
{% elif blk._flowblock == 'image' %} {% elif blk._flowblock == 'image' %}
<img src="{{ blk.image }}" alt="{{ blk.alt }}"> <img src="{{ blk.image }}" alt="{{ blk.alt }}">
{% endif %} {% endif %}

View File

@ -101,6 +101,7 @@ page.
<a href="{{ post|url }}">{{ post.title }}</a> — <a href="{{ post|url }}">{{ post.title }}</a> —
by {{ post.author }} by {{ post.author }}
on {{ post.pub_date|dateformat }} on {{ post.pub_date|dateformat }}
</li>
{% endfor %} {% endfor %}
</ul> </ul>

View File

@ -152,7 +152,7 @@ template globals when the environment is initialized. This means that we
can access this function from templates then: can access this function from templates then:
```html+jinja ```html+jinja
<p>Message of the page: {{ get_random_message() }} <p>Message of the page: {{ get_random_message() }}</p>
``` ```
There are many events that can be hooked and they can be found in the There are many events that can be hooked and they can be found in the