Use built-in filters#
Cookieplone registers a set of Jinja2 filters that you can use in template files, computed field defaults, and any other Jinja2 expression within your template.
Use a filter in a template file#
In any Jinja2-templated file inside your template, apply a filter with the | operator:
# {{ cookiecutter.python_package_name | pascal_case }} package
If python_package_name is my_plone_addon, the rendered output is:
# MyPloneAddon package
Use a filter in a computed field default#
In cookieplone.json, use filters inside computed field expressions:
{
"class_name": {
"type": "string",
"format": "computed",
"default": "{{ cookiecutter.python_package_name | pascal_case }}"
},
"namespace_path": {
"type": "string",
"format": "computed",
"default": "{{ cookiecutter.python_package_name | package_namespace_path }}"
}
}
Use a filter in a directory or file name#
Jinja2 expressions in directory names and file names are also rendered.
Name a directory {{cookiecutter.python_package_name | package_path}} and Cookieplone creates the path src/my_namespace/my_plone_addon.
Available filters#
See Filters reference for the full list of built-in filters with signatures and examples. The most commonly used ones include:
Filter |
Purpose |
|---|---|
|
Last segment of a dotted package name |
|
All segments except the last |
|
Dotted name as a filesystem path under |
|
Underscore-separated name in PascalCase |
|
Latest released Plone version |
|
Latest released Volto version |
|
Supported Python versions for a given Plone version |
|
Version string truncated to |