Skip to content

Commit 66c3078

Browse files
Normalize component names to use dot separators instead of slashes (#132)
1 parent 7694c26 commit 66c3078

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ and this project attempts to adhere to [Semantic Versioning](https://semver.org/
2222

2323
- Improved component context handling by using `Context` objects directly when a component uses the outside template context, instead of flattening the context `dict`.
2424
- **Internal**: Renamed `only` argument for `BirdNode` to `isolated_context`. This doesn't affect the public API of passing `only` to the template tag.
25+
- Standardized component names to use dots instead of slashes for nested paths (e.g., "nested.button" instead of "nested/button").
2526

2627
## [0.11.1]
2728

src/django_bird/components.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def discover_components(self) -> None:
112112
for component_path in component_dir.rglob("*.html"):
113113
component_name = str(
114114
component_path.relative_to(component_dir).with_suffix("")
115-
)
115+
).replace("/", ".")
116116
try:
117117
component = Component.from_name(component_name)
118118
self._components[component_name] = component

tests/test_components.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def test_nested_components(self, templates_dir):
218218

219219
components.discover_components()
220220

221-
assert "nested/button" in components._components
221+
assert "nested.button" in components._components
222222

223223
def test_component_name_collision(self, templates_dir, override_app_settings):
224224
TestComponent(

0 commit comments

Comments
 (0)