Filters reference#
Cookieplone registers these Jinja2 filters automatically for every template.
Use them with the | operator in template files, computed field defaults, and directory names.
All filters are defined in cookieplone/filters/__init__.py using the @simple_filter decorator from cookiecutter.utils.
package_name#
Signature: package_name(v: str) -> str
Returns the last segment of a dotted Python package name.
Input |
Output |
|---|---|
|
|
|
|
|
|
package_namespace#
Signature: package_namespace(v: str) -> str
Returns all segments of a dotted package name except the last one. Returns an empty string when there is no namespace.
Input |
Output |
|---|---|
|
|
|
|
|
|
package_namespaces#
Signature: package_namespaces(v: str) -> str
Returns a comma-separated string of all namespace prefixes formatted for use in setup.py.
Input |
Output |
|---|---|
|
|
|
|
|
|
package_namespace_path#
Signature: package_namespace_path(v: str) -> str
Returns the path to the top-level namespace package under src/.
Input |
Output |
|---|---|
|
|
|
|
package_path#
Signature: package_path(v: str) -> str
Returns the full package path relative to src/, replacing dots with slashes.
Input |
Output |
|---|---|
|
|
|
|
|
|
pascal_case#
Signature: pascal_case(package_name: str) -> str
Converts an underscore-separated name to PascalCase (title-casing each segment).
Input |
Output |
|---|---|
|
|
|
|
extract_host#
Signature: extract_host(hostname: str) -> str
Returns the first segment of a dotted hostname.
Input |
Output |
|---|---|
|
|
|
|
use_prerelease_versions#
Signature: use_prerelease_versions(_: str) -> str
Returns "Yes" when the environment variable USE_PRERELEASE is set; otherwise "No".
The input value is ignored.
|
Output |
|---|---|
Yes |
|
No |
|
latest_volto#
Signature: latest_volto(use_prerelease_versions: str) -> str
Returns the latest released version of Volto.
Pass "Yes" to include pre-releases.
Input |
Output (example) |
|---|---|
|
|
|
|
Requires internet access.
latest_plone#
Signature: latest_plone(use_prerelease_versions: str) -> str
Returns the latest released version of Plone.
Pass "Yes" to include pre-releases.
Input |
Output (example) |
|---|---|
|
|
|
|
Requires internet access.
python_versions#
Signature: python_versions(plone_version: str) -> list[str]
Returns the list of Python versions supported by the given Plone version.
Input |
Output (example) |
|---|---|
|
|
|
|
python_version_earliest#
Signature: python_version_earliest(plone_version: str) -> str
Returns the earliest Python version supported by the given Plone version.
Input |
Output |
|---|---|
|
|
|
|
python_version_latest#
Signature: python_version_latest(plone_version: str) -> str
Returns the latest Python version supported by the given Plone version.
Input |
Output |
|---|---|
|
|
|
|
node_version_for_volto#
Signature: node_version_for_volto(volto_version: str) -> int
Returns the recommended Node.js major version for the given Volto version.
Input |
Output (example) |
|---|---|
|
|
|
|
gs_language_code#
Signature: gs_language_code(code: str) -> str
Converts a language code to the format expected by Plone's Generic Setup (lowercase base, lowercase country).
Input |
Output |
|---|---|
|
|
|
|
|
|
locales_language_code#
Signature: locales_language_code(code: str) -> str
Converts a language code to the format expected by GNU gettext (lowercase base, uppercase country, underscore separator).
Input |
Output |
|---|---|
|
|
|
|
|
|
image_prefix#
Signature: image_prefix(registry: str) -> str
Returns the Docker image prefix for the given registry hostname.
as_semver#
Signature: as_semver(v: str) -> str
Converts a PEP 440 version string to SemVer format.
Input |
Output |
|---|---|
|
|
|
|
unscoped_package_name#
Signature: unscoped_package_name(v: str) -> str
Returns the unscoped name for a scoped npm package.
Input |
Output |
|---|---|
|
|
|
|
as_major_minor#
Signature: as_major_minor(v: str) -> str
Truncates a version string to MAJOR.MINOR.
Input |
Output |
|---|---|
|
|
|
|