Skip to content

Commit

Permalink
Added twig example of filtering to select episodes from a given year
Browse files Browse the repository at this point in the history
  • Loading branch information
skylogic004 authored Jun 20, 2024
1 parent dc71d07 commit 9f7eabb
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions publisher/guides/templates.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,24 @@ To use them in another template, you need to import the macros before using them
{% endraw %}
```

### Filters

Twig filters can be used to filter the list of episodes. For example, this filter selects only the episodes from the year 2024:

```handlebars
{% set filtered_episodes = podcast.episodes|filter(episode => episode.publicationDate.format('Y') == "2024") %}
<ul>
{% for episode in filtered_episodes %}
<li>
<a href="{{ episode.url }}">
{{ episode.title }}
</a> — {{ episode.subtitle }}
</li>
{% endfor %}
</ul>
```

## Creating PHP Templates — For Theme Developers

_Available from Podlove Publisher version 2.3_
Expand Down

0 comments on commit 9f7eabb

Please sign in to comment.