Skip to content

Commit e2af643

Browse files
committed
Handle creating nested components from startunicorn. #299
1 parent 47893a7 commit e2af643

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

django_unicorn/management/commands/startunicorn.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,20 @@ def handle(self, *args, **options):
106106

107107
(component_base_path / "__init__.py").touch(exist_ok=True)
108108

109+
nested_paths = []
110+
109111
for component_name in options["component_names"]:
112+
if "." in component_name:
113+
(*nested_paths, component_name) = component_name.split(".")
114+
115+
for nested_path in nested_paths:
116+
component_base_path /= nested_path
117+
118+
if not component_base_path.exists():
119+
component_base_path.mkdir()
120+
121+
(component_base_path / "__init__.py").touch(exist_ok=True)
122+
110123
snake_case_component_name = convert_to_snake_case(component_name)
111124
pascal_case_component_name = convert_to_pascal_case(component_name)
112125

@@ -135,6 +148,12 @@ def handle(self, *args, **options):
135148

136149
template_base_path.mkdir()
137150

151+
for nested_path in nested_paths:
152+
template_base_path /= nested_path
153+
154+
if not template_base_path.exists():
155+
template_base_path.mkdir()
156+
138157
template_path = template_base_path / f"{component_name}.html"
139158

140159
if template_path.exists():

0 commit comments

Comments
 (0)