django-components 0.111__tar.gz → 0.112__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django_components-0.111/src/django_components.egg-info → django_components-0.112}/PKG-INFO +1 -1
- {django_components-0.111 → django_components-0.112}/pyproject.toml +1 -1
- {django_components-0.111 → django_components-0.112}/src/django_components/component.py +0 -14
- {django_components-0.111 → django_components-0.112}/src/django_components/components/dynamic.py +0 -10
- {django_components-0.111 → django_components-0.112}/src/django_components/slots.py +21 -35
- {django_components-0.111 → django_components-0.112/src/django_components.egg-info}/PKG-INFO +1 -1
- {django_components-0.111 → django_components-0.112}/LICENSE +0 -0
- {django_components-0.111 → django_components-0.112}/MANIFEST.in +0 -0
- {django_components-0.111 → django_components-0.112}/README.md +0 -0
- {django_components-0.111 → django_components-0.112}/setup.cfg +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/__init__.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/app_settings.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/apps.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/attributes.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/autodiscovery.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/component_media.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/component_registry.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/components/__init__.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/context.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/dependencies.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/expression.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/finders.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/library.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/management/__init__.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/management/commands/__init__.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/management/commands/startcomponent.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/management/commands/upgradecomponent.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/middleware.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/node.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/provide.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/py.typed +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/static/django_components/django_components.min.js +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/tag_formatter.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/template.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/template_loader.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/template_parser.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/templatetags/__init__.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/templatetags/component_tags.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/types.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/urls.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/util/__init__.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/util/cache.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/util/html.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/util/loader.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/util/logger.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/util/misc.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/util/nanoid.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/util/tag_parser.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/util/types.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components/util/validation.py +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components.egg-info/SOURCES.txt +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components.egg-info/dependency_links.txt +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components.egg-info/requires.txt +0 -0
- {django_components-0.111 → django_components-0.112}/src/django_components.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "django_components"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.112"
|
|
8
8
|
requires-python = ">=3.8, <4.0"
|
|
9
9
|
description = "A way to create simple reusable template components in Django."
|
|
10
10
|
keywords = ["django", "components", "css", "js", "html"]
|
|
@@ -140,16 +140,6 @@ class ComponentVars(NamedTuple):
|
|
|
140
140
|
</div>
|
|
141
141
|
{% endif %}
|
|
142
142
|
```
|
|
143
|
-
|
|
144
|
-
This is equivalent to checking if a given key is among the slot fills:
|
|
145
|
-
|
|
146
|
-
```py
|
|
147
|
-
class MyTable(Component):
|
|
148
|
-
def get_context_data(self, *args, **kwargs):
|
|
149
|
-
return {
|
|
150
|
-
"my_slot_filled": "my_slot" in self.input.slots
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
143
|
"""
|
|
154
144
|
|
|
155
145
|
|
|
@@ -716,10 +706,6 @@ class Component(
|
|
|
716
706
|
# Get the component's HTML
|
|
717
707
|
html_content = template.render(context)
|
|
718
708
|
|
|
719
|
-
# After we've rendered the contents, we now know what slots were there,
|
|
720
|
-
# and thus we can validate that.
|
|
721
|
-
component_slot_ctx.post_render_validation()
|
|
722
|
-
|
|
723
709
|
# Allow to optionally override/modify the rendered content
|
|
724
710
|
new_output = self.on_render_after(context, template, html_content)
|
|
725
711
|
html_content = new_output if new_output is not None else html_content
|
{django_components-0.111 → django_components-0.112}/src/django_components/components/dynamic.py
RENAMED
|
@@ -35,16 +35,6 @@ class DynamicComponent(Component):
|
|
|
35
35
|
{% endcomponent %}
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
Or in case you use the `django_components.component_shorthand_formatter` tag formatter:
|
|
39
|
-
|
|
40
|
-
```django
|
|
41
|
-
{% dynamic is=table_comp data=table_data headers=table_headers %}
|
|
42
|
-
{% fill "pagination" %}
|
|
43
|
-
{% component "pagination" / %}
|
|
44
|
-
{% endfill %}
|
|
45
|
-
{% enddynamic %}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
38
|
Python
|
|
49
39
|
```py
|
|
50
40
|
from django_components import DynamicComponent
|
|
@@ -148,41 +148,6 @@ class ComponentSlotContext:
|
|
|
148
148
|
default_slot: Optional[str]
|
|
149
149
|
fills: Dict[SlotName, Slot]
|
|
150
150
|
|
|
151
|
-
def post_render_validation(self) -> None:
|
|
152
|
-
if self.is_dynamic_component:
|
|
153
|
-
return
|
|
154
|
-
|
|
155
|
-
default_fill = self.fills.get(DEFAULT_SLOT_KEY, None)
|
|
156
|
-
|
|
157
|
-
# Check: Only component templates that include a 'default' slot
|
|
158
|
-
# can be invoked with implicit filling.
|
|
159
|
-
if default_fill and not self.default_slot:
|
|
160
|
-
raise TemplateSyntaxError(
|
|
161
|
-
f"Component '{self.component_name}' passed default fill content "
|
|
162
|
-
f"(i.e. without explicit 'name' kwarg), "
|
|
163
|
-
f"even though none of its slots is marked as 'default'."
|
|
164
|
-
)
|
|
165
|
-
|
|
166
|
-
# NOTE:
|
|
167
|
-
# In the current implementation, the slots are resolved only at the render time.
|
|
168
|
-
# So when we are rendering Django's Nodes, and we come across a SlotNode, only
|
|
169
|
-
# at that point we check if we have the fill for it.
|
|
170
|
-
#
|
|
171
|
-
# That means that we can use variables, and we can place slots in loops.
|
|
172
|
-
#
|
|
173
|
-
# However, because the slot names are dynamic, we cannot know all the slot names
|
|
174
|
-
# that will be rendered ahead of the time.
|
|
175
|
-
#
|
|
176
|
-
# Moreover, user may define a slot whose default content has more slots inside it.
|
|
177
|
-
#
|
|
178
|
-
# Previously, there was an error raised if there were unfilled slots or extra fills.
|
|
179
|
-
#
|
|
180
|
-
# But now this is only a message. Because:
|
|
181
|
-
# 1. We don't know about ALL slots, just about the rendered ones, so we CANNOT check
|
|
182
|
-
# for unfilled slots (rendered slots WILL raise an error if the fill is missing).
|
|
183
|
-
# 2. User may provide extra fills, but these may belong to slots we haven't
|
|
184
|
-
# encountered in this render run. So we CANNOT say which ones are extra.
|
|
185
|
-
|
|
186
151
|
|
|
187
152
|
class SlotNode(BaseNode):
|
|
188
153
|
"""Node corresponding to `{% slot %}`"""
|
|
@@ -214,6 +179,27 @@ class SlotNode(BaseNode):
|
|
|
214
179
|
def __repr__(self) -> str:
|
|
215
180
|
return f"<Slot Node: {self.node_id}. Contents: {repr(self.nodelist)}. Options: {self.active_flags}>"
|
|
216
181
|
|
|
182
|
+
# NOTE:
|
|
183
|
+
# In the current implementation, the slots are resolved only at the render time.
|
|
184
|
+
# So when we are rendering Django's Nodes, and we come across a SlotNode, only
|
|
185
|
+
# at that point we check if we have the fill for it.
|
|
186
|
+
#
|
|
187
|
+
# That means that we can use variables, and we can place slots in loops.
|
|
188
|
+
#
|
|
189
|
+
# However, because the slot names are dynamic, we cannot know all the slot names
|
|
190
|
+
# that will be rendered ahead of the time.
|
|
191
|
+
#
|
|
192
|
+
# Moreover, user may define a `{% slot %}` whose default content has more nested
|
|
193
|
+
# `{% slot %}` tags inside of it.
|
|
194
|
+
#
|
|
195
|
+
# Previously, there was an error raised if there were unfilled slots or extra fills,
|
|
196
|
+
# or if there was an extra fill for a default slot.
|
|
197
|
+
#
|
|
198
|
+
# But we don't raise those anymore, because:
|
|
199
|
+
# 1. We don't know about ALL slots, just about the rendered ones, so we CANNOT check
|
|
200
|
+
# for unfilled slots (rendered slots WILL raise an error if the fill is missing).
|
|
201
|
+
# 2. User may provide extra fills, but these may belong to slots we haven't
|
|
202
|
+
# encountered in this render run. So we CANNOT say which ones are extra.
|
|
217
203
|
def render(self, context: Context) -> SafeString:
|
|
218
204
|
trace_msg("RENDR", "SLOT", self.trace_id, self.node_id)
|
|
219
205
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_components-0.111 → django_components-0.112}/src/django_components/component_media.py
RENAMED
|
File without changes
|
{django_components-0.111 → django_components-0.112}/src/django_components/component_registry.py
RENAMED
|
File without changes
|
{django_components-0.111 → django_components-0.112}/src/django_components/components/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_components-0.111 → django_components-0.112}/src/django_components/management/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_components-0.111 → django_components-0.112}/src/django_components/template_loader.py
RENAMED
|
File without changes
|
{django_components-0.111 → django_components-0.112}/src/django_components/template_parser.py
RENAMED
|
File without changes
|
{django_components-0.111 → django_components-0.112}/src/django_components/templatetags/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_components-0.111 → django_components-0.112}/src/django_components/util/tag_parser.py
RENAMED
|
File without changes
|
|
File without changes
|
{django_components-0.111 → django_components-0.112}/src/django_components/util/validation.py
RENAMED
|
File without changes
|
{django_components-0.111 → django_components-0.112}/src/django_components.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{django_components-0.111 → django_components-0.112}/src/django_components.egg-info/requires.txt
RENAMED
|
File without changes
|
{django_components-0.111 → django_components-0.112}/src/django_components.egg-info/top_level.txt
RENAMED
|
File without changes
|