Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow sub directories for components #299

Closed
riquedev opened this issue Oct 27, 2021 · 2 comments
Closed

Allow sub directories for components #299

riquedev opened this issue Oct 27, 2021 · 2 comments
Assignees

Comments

@riquedev
Copy link

riquedev commented Oct 27, 2021

Wouldn't it be interesting to enable the creation of subfolders inside components?
It is currently possible as long as we create the folders in advance.

The "event" folder was previously created

...> python manage.py  startunicorn "ABXSite" event\schedule
Created ...\components\event\schedule.py.
Created ...\templates\unicorn\event\schedule.html.

However, you cannot use components in subdirectories, perhaps a schema like:

{% unicorn "folder:component" %}

As in {% url "appname:view" %}

@adamghill
Copy link
Owner

Nested components are supported. You can see an example in https://github.com/adamghill/django-unicorn/tree/master/example/unicorn/components/nested and https://github.com/adamghill/django-unicorn/tree/master/example/unicorn/templates/unicorn/nested. You use a . (like Python namespaces) to access components in sub-folders. An example of that is:

{% unicorn 'nested.filter' parent=view %}
.

However, I'm not sure if the startunicorn supports creating folders for nested components, but that seems relatively easy to add in if it would be useful. And I can add some documentation around this capability as well!

@adamghill
Copy link
Owner

adamghill commented Dec 18, 2021

This has been merged into master and will be released in 0.40.0. I also added documentation to https://www.django-unicorn.com/docs/components/#component-sub-folders and https://www.django-unicorn.com/docs/cli/#sub-folders.

will9288 added a commit to will9288/django-unicorn that referenced this issue May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants