35 lines
771 B
Markdown
35 lines
771 B
Markdown
title: or
|
|
---
|
|
summary: True if either left and right side are true.
|
|
---
|
|
type: method
|
|
---
|
|
signature: other
|
|
---
|
|
body:
|
|
|
|
This evaluates to true if either the expression on the left or the
|
|
expression on the right are true. This is one of the few operators that
|
|
differs between Python and templates. In templates you have to use the
|
|
`or` method whereas in Python have to use the `|` operator.
|
|
|
|
## Template Example
|
|
|
|
```html+jinja
|
|
<h3>Hotels or Apartments</h3>
|
|
<ul>
|
|
{% for item in this.children.filter(
|
|
(F.type == 'hotel').or(F.type == 'apartment')) %}
|
|
<li>{{ item.name }} ({{ item.type}})
|
|
{% endfor %}
|
|
</ul>
|
|
```
|
|
|
|
## Python Example
|
|
|
|
```python
|
|
def get_hotels_or_apartments(page):
|
|
return page.children.filter(
|
|
(F.type == 'hotel') | (F.type == 'apartment'))
|
|
```
|