django-components 0.111__tar.gz → 0.113__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.113}/PKG-INFO +1 -1
- {django_components-0.111 → django_components-0.113}/pyproject.toml +1 -1
- {django_components-0.111 → django_components-0.113}/src/django_components/component.py +0 -14
- {django_components-0.111 → django_components-0.113}/src/django_components/components/dynamic.py +0 -10
- {django_components-0.111 → django_components-0.113}/src/django_components/dependencies.py +14 -7
- {django_components-0.111 → django_components-0.113}/src/django_components/slots.py +21 -35
- {django_components-0.111 → django_components-0.113/src/django_components.egg-info}/PKG-INFO +1 -1
- {django_components-0.111 → django_components-0.113}/LICENSE +0 -0
- {django_components-0.111 → django_components-0.113}/MANIFEST.in +0 -0
- {django_components-0.111 → django_components-0.113}/README.md +0 -0
- {django_components-0.111 → django_components-0.113}/setup.cfg +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/__init__.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/app_settings.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/apps.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/attributes.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/autodiscovery.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/component_media.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/component_registry.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/components/__init__.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/context.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/expression.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/finders.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/library.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/management/__init__.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/management/commands/__init__.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/management/commands/startcomponent.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/management/commands/upgradecomponent.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/middleware.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/node.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/provide.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/py.typed +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/static/django_components/django_components.min.js +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/tag_formatter.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/template.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/template_loader.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/template_parser.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/templatetags/__init__.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/templatetags/component_tags.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/types.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/urls.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/util/__init__.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/util/cache.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/util/html.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/util/loader.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/util/logger.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/util/misc.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/util/nanoid.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/util/tag_parser.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/util/types.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components/util/validation.py +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components.egg-info/SOURCES.txt +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components.egg-info/dependency_links.txt +0 -0
- {django_components-0.111 → django_components-0.113}/src/django_components.egg-info/requires.txt +0 -0
- {django_components-0.111 → django_components-0.113}/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.113"
|
|
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.113}/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
|
|
@@ -433,7 +433,9 @@ def _process_dep_declarations(content: bytes, type: RenderType) -> Tuple[bytes,
|
|
|
433
433
|
|
|
434
434
|
content = COMPONENT_COMMENT_REGEX.sub(on_replace_match, content)
|
|
435
435
|
|
|
436
|
-
|
|
436
|
+
# NOTE: Python's set does NOT preserve order
|
|
437
|
+
seen_comp_hashes: Set[str] = set()
|
|
438
|
+
comp_hashes: List[str] = []
|
|
437
439
|
|
|
438
440
|
# Process individual parts. Each part is like a CSV row of `name,id`.
|
|
439
441
|
# E.g. something like this:
|
|
@@ -445,7 +447,11 @@ def _process_dep_declarations(content: bytes, type: RenderType) -> Tuple[bytes,
|
|
|
445
447
|
raise RuntimeError("Malformed dependencies data")
|
|
446
448
|
|
|
447
449
|
comp_cls_hash = part_match.group("comp_cls_hash").decode("utf-8")
|
|
448
|
-
|
|
450
|
+
if comp_cls_hash in seen_comp_hashes:
|
|
451
|
+
continue
|
|
452
|
+
|
|
453
|
+
comp_hashes.append(comp_cls_hash)
|
|
454
|
+
seen_comp_hashes.add(comp_cls_hash)
|
|
449
455
|
|
|
450
456
|
(
|
|
451
457
|
to_load_component_js_urls,
|
|
@@ -534,7 +540,7 @@ def _postprocess_media_tags(
|
|
|
534
540
|
script_type: ScriptType,
|
|
535
541
|
tags: List[str],
|
|
536
542
|
) -> Tuple[List[str], List[str]]:
|
|
537
|
-
|
|
543
|
+
urls: List[str] = []
|
|
538
544
|
tags_by_url: Dict[str, str] = {}
|
|
539
545
|
|
|
540
546
|
for tag in tags:
|
|
@@ -549,15 +555,16 @@ def _postprocess_media_tags(
|
|
|
549
555
|
f"value for attribute '{attr}'. Got:\n{tag}"
|
|
550
556
|
)
|
|
551
557
|
|
|
558
|
+
url = cast(str, maybe_url)
|
|
559
|
+
|
|
552
560
|
# Skip duplicates
|
|
553
|
-
if
|
|
561
|
+
if url in tags_by_url:
|
|
554
562
|
continue
|
|
555
563
|
|
|
556
|
-
url = cast(str, maybe_url)
|
|
557
564
|
tags_by_url[url] = tag
|
|
558
|
-
|
|
565
|
+
urls.append(url)
|
|
559
566
|
|
|
560
|
-
|
|
567
|
+
# Ensure consistent order
|
|
561
568
|
tags = [tags_by_url[url] for url in urls]
|
|
562
569
|
|
|
563
570
|
return tags, urls
|
|
@@ -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.113}/src/django_components/component_media.py
RENAMED
|
File without changes
|
{django_components-0.111 → django_components-0.113}/src/django_components/component_registry.py
RENAMED
|
File without changes
|
{django_components-0.111 → django_components-0.113}/src/django_components/components/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_components-0.111 → django_components-0.113}/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.113}/src/django_components/template_loader.py
RENAMED
|
File without changes
|
{django_components-0.111 → django_components-0.113}/src/django_components/template_parser.py
RENAMED
|
File without changes
|
{django_components-0.111 → django_components-0.113}/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.113}/src/django_components/util/tag_parser.py
RENAMED
|
File without changes
|
|
File without changes
|
{django_components-0.111 → django_components-0.113}/src/django_components/util/validation.py
RENAMED
|
File without changes
|
{django_components-0.111 → django_components-0.113}/src/django_components.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{django_components-0.111 → django_components-0.113}/src/django_components.egg-info/requires.txt
RENAMED
|
File without changes
|
{django_components-0.111 → django_components-0.113}/src/django_components.egg-info/top_level.txt
RENAMED
|
File without changes
|