feat: Support filters for template strings #3677 (#4396)

This commit is contained in:
KoljaTM
2020-10-25 16:29:59 +01:00
committed by GitHub
parent a690e467fa
commit 1fa108ee67
3 changed files with 80 additions and 4 deletions

View File

@ -493,6 +493,27 @@ Example config:
max_file_size: 512000 # in bytes, only for default media library
```
## Summary string template transformations
You can apply transformations on fields in a summary string template using filter notation syntax.
Example config:
```yaml
collections:
- name: 'posts'
label: 'Posts'
folder: '_posts'
summary: "{{title | upper}} - {{date | date('YYYY-MM-DD')}}"
fields:
- { label: 'Title', name: 'title', widget: 'string' }
- { label: 'Publish Date', name: 'date', widget: 'datetime' }
```
The above config will transform the title field to uppercase and format the date field using `YYYY-MM-DD` format.
Available transformations are `upper`, `lower` and `date('<format>')`
## Registering to CMS Events
You can execute a function when a specific CMS event occurs.