Close HTML tags in template examples.
This commit is contained in:
parent
45014ce289
commit
f75fc6fc80
|
@ -20,7 +20,7 @@ differs between Python and templates. In templates you have to use the
|
|||
<ul>
|
||||
{% for item in this.children.filter(
|
||||
(F.type == 'hotel').and(F.stars >= 3)) %}
|
||||
<li>{{ item.name }}: {{ item.stars }} stars
|
||||
<li>{{ item.name }}: {{ item.stars }} stars</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -19,7 +19,7 @@ contained in another string or a item can be contained within a list.
|
|||
<h3>Projects Tagged 'amazing'</h3>
|
||||
<ul>
|
||||
{% for item in this.children.filter(F.tags.contains('amazing')) %}
|
||||
<li>{{ item.name }}
|
||||
<li>{{ item.name }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -18,7 +18,7 @@ see [endswith :ref](../endswith/).
|
|||
```html+jinja
|
||||
<ul>
|
||||
{% for item in this.children.filter(F.name.endswith_cs('House')) %}
|
||||
<li>{{ item.name }}
|
||||
<li>{{ item.name }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -18,7 +18,7 @@ see [endswith_cs :ref](../endswith-cs/).
|
|||
```html+jinja
|
||||
<ul>
|
||||
{% for item in this.children.filter(F.name.endswith('house')) %}
|
||||
<li>{{ item.name }}
|
||||
<li>{{ item.name }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -15,7 +15,7 @@ Typically it compares if a value matches a specific value exactly:
|
|||
<h2>Our Houses</h2>
|
||||
<ul>
|
||||
{% for project in this.children.filter(F.type == 'house') %}
|
||||
<li>{{ project.name }}
|
||||
<li>{{ project.name }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -16,7 +16,7 @@ or equal to it. This behavior works best with [integers
|
|||
<h3>3 or more Stars</h3>
|
||||
<ul>
|
||||
{% for item in this.children.filter(F.stars >= 3) %}
|
||||
<li>{{ item.name }}: {{ item.stars }} stars
|
||||
<li>{{ item.name }}: {{ item.stars }} stars</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -16,7 +16,7 @@ or [floats :ref](../../types/float/).
|
|||
<h3>Well Rated Items</h3>
|
||||
<ul>
|
||||
{% for item in this.children.filter(F.stars > 3) %}
|
||||
<li>{{ item.name }}: {{ item.stars }} stars
|
||||
<li>{{ item.name }}: {{ item.stars }} stars</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -16,7 +16,7 @@ or equal to it. This behavior works best with [integers
|
|||
<h3>Projects From Before Including 2000</h3>
|
||||
<ul>
|
||||
{% for item in this.children.filter(F.year <= 2000) %}
|
||||
<li>{{ item.name }} ({{ item.year }})
|
||||
<li>{{ item.name }} ({{ item.year }})</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -16,7 +16,7 @@ or equal to it. This behavior works best with [integers
|
|||
<h3>Projects From Before 2000</h3>
|
||||
<ul>
|
||||
{% for item in this.children.filter(F.year < 2000) %}
|
||||
<li>{{ item.name }} ({{ item.year }})
|
||||
<li>{{ item.name }} ({{ item.year }})</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -15,7 +15,7 @@ by doing a exact comparision:
|
|||
<h2>Everything Other Than Houses</h2>
|
||||
<ul>
|
||||
{% for project in this.children.filter(F.type != 'house') %}
|
||||
<li>{{ project.name }}
|
||||
<li>{{ project.name }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -20,7 +20,7 @@ differs between Python and templates. In templates you have to use the
|
|||
<ul>
|
||||
{% for item in this.children.filter(
|
||||
(F.type == 'hotel').or(F.type == 'apartment')) %}
|
||||
<li>{{ item.name }} ({{ item.type}})
|
||||
<li>{{ item.name }} ({{ item.type}})</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -19,7 +19,7 @@ see [startswith :ref](../startswith/).
|
|||
<h1>A</h1>
|
||||
<ul>
|
||||
{% for item in this.children.filter(F.name.startswith_cs('A')) %}
|
||||
<li>{{ item.name }}
|
||||
<li>{{ item.name }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -19,7 +19,7 @@ see [startswith_cs :ref](../startswith-cs/).
|
|||
<h1>A</h1>
|
||||
<ul>
|
||||
{% for item in this.children.filter(F.name.startswith('a')) %}
|
||||
<li>{{ item.name }}
|
||||
<li>{{ item.name }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -22,7 +22,7 @@ Accessing an attributes creates an [Expression :ref](../expression/).
|
|||
```html+jinja
|
||||
<ul>
|
||||
{% for item in this.children.filter(F.status == 'published') %}
|
||||
<li>{{ item.title }}
|
||||
<li>{{ item.title }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -24,6 +24,6 @@ source objects is that they are always visible.
|
|||
```html+jinja
|
||||
{% set downloads = site.get('/downloads') %}
|
||||
{% if downloads.is_hidden %}
|
||||
<p>Downloads are currently unavailable
|
||||
<p>Downloads are currently unavailable</p>
|
||||
{% endif %}
|
||||
```
|
||||
|
|
|
@ -14,5 +14,5 @@ where this property can be used to discover the associated parent object.
|
|||
## Example
|
||||
|
||||
```html+jinja
|
||||
<p>My parent is: {{ this.parent.path }}
|
||||
<p>My parent is: {{ this.parent.path }}</p>
|
||||
```
|
||||
|
|
|
@ -33,7 +33,7 @@ Here another example that loads the current page but in another language:
|
|||
|
||||
```html+jinja
|
||||
{% 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
|
||||
|
|
|
@ -18,7 +18,7 @@ and will also include hidden pages.
|
|||
```html+jinja
|
||||
<ul>
|
||||
{% for project in site.query('/projects') %}
|
||||
<li>{{ project.name }}: {{ project.year }}
|
||||
<li>{{ project.name }}: {{ project.year }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -18,7 +18,7 @@ handy.
|
|||
{% if items %}
|
||||
<ul>
|
||||
{% for item in items %}
|
||||
<li>{{ item.name }}
|
||||
<li>{{ item.name }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
|
|
@ -22,7 +22,7 @@ Here a basic example of how to filter something in a template:
|
|||
```html+jinja
|
||||
<ul>
|
||||
{% for item in this.children.filter(F.status == 'published') %}
|
||||
<li>{{ item.title }}
|
||||
<li>{{ item.title }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -12,5 +12,5 @@ This is a simple way to count the total number of items a query matches.
|
|||
|
||||
```html+jinja
|
||||
{% set project_count = site.query('/projects').count() %}
|
||||
<p>We built {{ project_count }} projects.
|
||||
<p>We built {{ project_count }} projects.</p>
|
||||
```
|
||||
|
|
|
@ -22,7 +22,7 @@ Here a basic example of how to filter something in a template:
|
|||
```html+jinja
|
||||
<ul>
|
||||
{% for item in this.children.filter(F.status == 'published') %}
|
||||
<li>{{ item.title }}
|
||||
<li>{{ item.title }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -15,6 +15,6 @@ query. If no such record can be produced, `None` is returned.
|
|||
{% first_visible = this.children.first() %}
|
||||
{% if first_visible %}
|
||||
<h2>Explore More ...</h2>
|
||||
<p>{{ first_visible.title }}
|
||||
<p>{{ first_visible.title }}</p>
|
||||
{% endif %}
|
||||
```
|
||||
|
|
|
@ -18,5 +18,5 @@ requested page number from the query for pagination.
|
|||
```html+jinja
|
||||
{% set p1 = this.children.get('project-1') %}
|
||||
<h2>{{ p1.name }}</h2>
|
||||
<p>Our favorite!
|
||||
<p>Our favorite!</p>
|
||||
```
|
||||
|
|
|
@ -24,7 +24,7 @@ Here a basic example of how to filter something in a template:
|
|||
```html+jinja
|
||||
<ul>
|
||||
{% 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 %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -25,7 +25,7 @@ Here a basic example of how to filter something in a template:
|
|||
```html+jinja
|
||||
<ul>
|
||||
{% for item in this.children.include_undiscoverable(true) %}
|
||||
<li>{{ item.title }}
|
||||
<li>{{ item.title }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -17,7 +17,7 @@ of matching records.
|
|||
<h3>Our Top 3</h3>
|
||||
<ul>
|
||||
{% for item in this.children.order_by('-rating').limit(3) %}
|
||||
<li>{{ item.title }}
|
||||
<li>{{ item.title }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -23,7 +23,7 @@ order by year and within a year it will order by name.
|
|||
```html+jinja
|
||||
<ul>
|
||||
{% for project in this.children.order_by('-year', 'name') %}
|
||||
<li>{{ project.year }}: {{ project.name }}
|
||||
<li>{{ project.year }}: {{ project.name }}</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -25,6 +25,7 @@ there is a good reason to use it.
|
|||
<li>
|
||||
Items on the first page of {{ child.title }}:
|
||||
{{ child.pagination.items.count() }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -27,7 +27,7 @@ via the [query :ref](../../pad/query/) method of the pad.
|
|||
```html+jinja
|
||||
<ul>
|
||||
{% for child in this.children %}
|
||||
<li>{{ child.title }}
|
||||
<li>{{ child.title }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -25,6 +25,6 @@ attribute overlaps with your custom field, you need to access the fields
|
|||
with the subscript syntax (`[]`):
|
||||
|
||||
```html+jinja
|
||||
<p>Built-in Path: {{ obj.path }}
|
||||
<p>Path field: {{ obj['path'] }}
|
||||
<p>Built-in Path: {{ obj.path }}</p>
|
||||
<p>Path field: {{ obj['path'] }}</p>
|
||||
```
|
||||
|
|
|
@ -13,6 +13,6 @@ only implemented for attachments that are images.
|
|||
|
||||
```html+jinja
|
||||
{% for image in this.attachments.images %}
|
||||
<p>{{ image._id }}: {{ image.format }}
|
||||
<p>{{ image._id }}: {{ image.format }}</p>
|
||||
{% endfor %}
|
||||
```
|
||||
|
|
|
@ -42,7 +42,7 @@ page:
|
|||
```html+jinja
|
||||
<ul>
|
||||
{% for child in this.pagination.items %}
|
||||
<li>{{ child.title }}
|
||||
<li>{{ child.title }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -17,7 +17,7 @@ This field is most useful for filtering when operating on mixed collections.
|
|||
```html+jinja
|
||||
<ul class="projects">
|
||||
{% for child in this.children.filter(F._model == 'project') %}
|
||||
<li>{{ child.name }}
|
||||
<li>{{ child.name }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -23,5 +23,5 @@ type = date
|
|||
## Template Usage
|
||||
|
||||
```html+jinja
|
||||
<p>Published: {{ this.pub_date.strftime('%d/%m/%Y') }}
|
||||
<p>Published: {{ this.pub_date.strftime('%d/%m/%Y') }}</p>
|
||||
```
|
||||
|
|
|
@ -28,7 +28,7 @@ description = A list of things that would be good to buy
|
|||
<h2>Shopping List</h2>
|
||||
<ul>
|
||||
{% for item in this.things_to_buy %}
|
||||
<li>{{ item }}
|
||||
<li>{{ item }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
|
|
@ -31,11 +31,11 @@ more information see [CLDR Date/Time Symbols
|
|||
## Examples
|
||||
|
||||
```html+jinja
|
||||
<p>Date: {{ this.pub_date|dateformat('full') }}
|
||||
<p>Date: {{ this.pub_date|dateformat('full') }}</p>
|
||||
```
|
||||
|
||||
Or with custom CLDR format strings:
|
||||
|
||||
```html+jinja
|
||||
<p>Date: {{ this.pub_date|dateformat('EEE, MMM d, ''yy') }}
|
||||
<p>Date: {{ this.pub_date|dateformat('EEE, MMM d, ''yy') }}</p>
|
||||
```
|
||||
|
|
|
@ -15,6 +15,6 @@ and [latlongformat :ref](../latlongformat/).
|
|||
## Examples
|
||||
|
||||
```html+jinja
|
||||
<p>Lat: {{ image.exif.latitude|latformat }}
|
||||
<p>Long: {{ image.exif.longitude|longformat }}
|
||||
<p>Lat: {{ image.exif.latitude|latformat }}</p>
|
||||
<p>Long: {{ image.exif.longitude|longformat }}</p>
|
||||
```
|
||||
|
|
|
@ -15,5 +15,5 @@ in the format format degrees, minutes and seconds. See also [latformat
|
|||
## Examples
|
||||
|
||||
```html+jinja
|
||||
<p>Location: {{ image.exif.location|latlongformat }}
|
||||
<p>Location: {{ image.exif.location|latlongformat }}</p>
|
||||
```
|
||||
|
|
|
@ -15,6 +15,6 @@ and [latlongformat :ref](../latlongformat/).
|
|||
## Examples
|
||||
|
||||
```html+jinja
|
||||
<p>Lat: {{ image.exif.latitude|latformat }}
|
||||
<p>Long: {{ image.exif.longitude|longformat }}
|
||||
<p>Lat: {{ image.exif.latitude|latformat }}</p>
|
||||
<p>Long: {{ image.exif.longitude|longformat }}</p>
|
||||
```
|
||||
|
|
|
@ -99,7 +99,7 @@ using their templates:
|
|||
```html+jinja
|
||||
{% for blk in this.demo_flow.blocks %}
|
||||
{% if blk._flowblock == 'text' %}
|
||||
<p>{{ blk.text }}
|
||||
<p>{{ blk.text }}</p>
|
||||
{% elif blk._flowblock == 'image' %}
|
||||
<img src="{{ blk.image }}" alt="{{ blk.alt }}">
|
||||
{% endif %}
|
||||
|
|
|
@ -101,6 +101,7 @@ page.
|
|||
<a href="{{ post|url }}">{{ post.title }}</a> —
|
||||
by {{ post.author }}
|
||||
on {{ post.pub_date|dateformat }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ template globals when the environment is initialized. This means that we
|
|||
can access this function from templates then:
|
||||
|
||||
```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
|
||||
|
|
Loading…
Reference in New Issue