lektor-website/content/docs/api/db/query/first/contents.lr

21 lines
401 B
Plaintext
Raw Normal View History

2015-12-19 14:52:17 +01:00
title: first
---
summary: Returns the first matching record.
---
type: method
---
body:
This method returns the first [Record :ref](../../record/) that matches the
query. If no such record can be produced, `None` is returned.
## Example
```html+jinja
2016-04-03 20:24:31 +02:00
{% set first_visible = this.children.first() %}
2015-12-19 14:52:17 +01:00
{% if first_visible %}
<h2>Explore More ...</h2>
<p>{{ first_visible.title }}
{% endif %}
```