Skip to content

Commit a8ecc55

Browse files
committed
Make sure we don't override existing filters
We also need to rename the `title` filter because we were overriding the jinja2 built-in filter with the same name. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent ebf178d commit a8ecc55

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

cookiecutter/cookiecutter.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
],
1010
"name": null,
1111
"description": null,
12-
"title": "{{cookiecutter | title}}",
12+
"title": "{{cookiecutter | proj_title}}",
1313
"keywords": "(comma separated: 'frequenz', <type> and <name> are included automatically)",
1414
"github_org": "frequenz-floss",
1515
"license": [

cookiecutter/local_extensions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def _register_filters(self) -> None:
5959
and name.endswith(self._FILTER_SUFFIX)
6060
]
6161
for filer_name in filters:
62+
if filer_name in self.environment.filters:
63+
raise ValueError(f"Filter {filer_name!r} already registered")
6264
attr_name = f"{self._FILTER_PREFIX}{filer_name}{self._FILTER_SUFFIX}"
6365
self.environment.filters[filer_name] = getattr(self, attr_name)
6466

@@ -139,7 +141,7 @@ def _github_repo_name_filter(self, cookiecutter: dict[str, str]) -> str:
139141
end = "-python" if cookiecutter["type"] == "lib" else ""
140142
return f"{pypi}{end}"
141143

142-
def _title_filter(self, cookiecutter: dict[str, str]) -> str:
144+
def _proj_title_filter(self, cookiecutter: dict[str, str]) -> str:
143145
"""Build a default mkdocs site name for the project.
144146
145147
Args:

0 commit comments

Comments
 (0)