@@ -45,7 +45,6 @@ your_app/
4545├── urls.py
4646└── sub_app/
4747 ├── __init__.py
48- ├── components.py
4948 ├── idom.py
5049 ├── templates/
5150 │ └── your-template.html
@@ -58,7 +57,7 @@ To start, we'll need to use [`channels`](https://channels.readthedocs.io/en/stab
5857create a ` ProtocolTypeRouter ` that will become the top of our ASGI application stack.
5958Under the ` "websocket" ` protocol, we'll then add a path for IDOM's websocket consumer
6059using ` idom_websocket_path ` . If you wish to change the route where this
61- websocket is served from see the available [ settings] ( #settings.py ) .
60+ websocket is served from, see the available [ settings] ( #settings.py ) .
6261
6362``` python
6463
@@ -104,15 +103,13 @@ You may configure additional options as well:
104103``` python
105104# the base URL for all IDOM-releated resources
106105IDOM_BASE_URL : str = " _idom/"
107-
108- # ignore these INSTALLED_APPS during component collection
109- IDOM_IGNORE_INSTALLED_APPS : list[str ] = [" some_app" , " some_other_app" ]
110106```
111107
112108## ` urls.py `
113109
114110You'll need to include IDOM's static web modules path using ` idom_web_modules_path ` .
115- Similarly to the ` idom_websocket_path() ` , these resources will be used globally.
111+ Similarly to the ` idom_websocket_path() ` . If you wish to change the route where this
112+ websocket is served from, see the available [ settings] ( #settings.py ) .
116113
117114``` python
118115from django_idom import idom_web_modules_path
@@ -128,54 +125,26 @@ urlpatterns = [
128125This is where, by a convention similar to that of
129126[ ` views.py ` ] ( https://docs.djangoproject.com/en/3.2/topics/http/views/ ) , you'll define
130127your [ IDOM] ( https://github.com/idom-team/idom ) components. Ultimately though, you should
131- feel free to organize your component modules you wish.
128+ feel free to organize your component modules you wish. The components created here will
129+ ultimately be referenced by name in ` your-template.html ` . ` your-template.html ` .
132130
133131``` python
134132import idom
135133
136134@idom.component
137135def Hello (name ): # component names are camelcase by convention
138- return idom.html.h1(f " Hello { name} ! " )
139- ```
140-
141- ## ` sub_app/idom.py `
142-
143- This file is automatically discovered by ` django-idom ` when scanning the list of
144- [ ` INSTALLED_APPS ` ] ( https://docs.djangoproject.com/en/3.2/ref/settings/#std:setting-INSTALLED_APPS ) .
145- All apps that export components will contain this module.
146-
147- Inside this module must be a ` components ` list that is imported from
148- [ ` components.py ` ] ( #sub_appcomponents.py ) :
149-
150- ``` python
151- from .components import Hello
152-
153- components = [
154- Hello,
155- ...
156- ]
157- ```
158-
159- You may alternately reference the components with strings for the purpose of renaming:
160-
161- ``` python
162- from .components import Hello as SomeOtherName
163-
164- components = [
165- " SomeOtherName" ,
166- ...
167- ]
136+ return Header(f " Hello { name} ! " )
168137```
169138
170139## ` sub_app/templates/your-template.html `
171140
172141In your templates, you may inject a view of an IDOM component into your templated HTML
173142by using the ` idom_view ` template tag. This tag which requires the name of a component
174- to render (of the form ` app_name .ComponentName` ) and keyword arguments you'd like to
143+ to render (of the form ` module_name .ComponentName` ) and keyword arguments you'd like to
175144pass it from the template.
176145
177146``` python
178- idom_view app_name .ComponentName param_1= " something" param_2= " something-else"
147+ idom_view module_name .ComponentName param_1= " something" param_2= " something-else"
179148```
180149
181150In context this will look a bit like the following...
@@ -189,7 +158,7 @@ In context this will look a bit like the following...
189158<html >
190159 <body >
191160 ...
192- {% idom_view "your_app.sub_app.Hello" name="World" %}
161+ {% idom_view "your_app.sub_app.components. Hello" name="World" %}
193162 </body >
194163</html >
195164```
0 commit comments