mirror of
https://github.com/django-components/django-components.git
synced 2025-08-04 14:28:18 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
5f07f3d4da
commit
a5a0c74d31
4 changed files with 7 additions and 8 deletions
|
@ -202,6 +202,7 @@ class Component(View, metaclass=SimplifiedInterfaceMediaDefiningClass):
|
|||
|
||||
class Media:
|
||||
"""Defines JS and CSS media files associated with this component."""
|
||||
|
||||
css: Optional[Union[str, List[str], Dict[str, str], Dict[str, List[str]]]] = None
|
||||
js: Optional[Union[str, List[str]]] = None
|
||||
|
||||
|
@ -492,14 +493,13 @@ class Component(View, metaclass=SimplifiedInterfaceMediaDefiningClass):
|
|||
) -> Dict[SlotName, FillContent]:
|
||||
"""Fill component slots outside of template rendering."""
|
||||
slot_fills = {}
|
||||
for (slot_name, content) in slots_data.items():
|
||||
for slot_name, content in slots_data.items():
|
||||
if isinstance(content, (str, SafeString)):
|
||||
content_func = nodelist_to_render_func(
|
||||
NodeList([
|
||||
TextNode(escape(content) if escape_content else content)
|
||||
])
|
||||
NodeList([TextNode(escape(content) if escape_content else content)])
|
||||
)
|
||||
else:
|
||||
|
||||
def content_func(ctx: Context) -> RenderedContent:
|
||||
rendered = content(ctx)
|
||||
return escape(rendered) if escape_content else rendered
|
||||
|
|
|
@ -13,6 +13,7 @@ RenderFunc = Callable[[Context], RenderedContent]
|
|||
def nodelist_to_render_func(nodelist: NodeList) -> RenderFunc:
|
||||
def render_func(ctx: Context) -> RenderedContent:
|
||||
return nodelist.render(ctx)
|
||||
|
||||
return render_func
|
||||
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ Tests focusing on the Component class.
|
|||
For tests focusing on the `component` tag, see `test_templatetags_component.py`
|
||||
"""
|
||||
|
||||
from django.http import HttpResponse
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.http import HttpResponse
|
||||
from django.template import Context, Template, TemplateSyntaxError
|
||||
|
||||
# isort: off
|
||||
|
|
|
@ -141,9 +141,7 @@ class InlineComponentTest(BaseTestCase):
|
|||
"var2": var2,
|
||||
}
|
||||
|
||||
rendered = FilteredComponent.render(
|
||||
kwargs={"var1": "test1", "var2": "test2"}
|
||||
)
|
||||
rendered = FilteredComponent.render(kwargs={"var1": "test1", "var2": "test2"})
|
||||
self.assertHTMLEqual(
|
||||
rendered,
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue