mirror of
https://github.com/django-components/django-components.git
synced 2025-09-25 15:09:15 +00:00
refactor: move kwargs resolution to render-time + cleanup (#594)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
83dcc3fe80
commit
899b9a2738
13 changed files with 448 additions and 371 deletions
|
@ -5,6 +5,25 @@ from django.template.base import Node, NodeList, TextNode
|
|||
from django.template.defaulttags import CommentNode
|
||||
from django.template.loader_tags import ExtendsNode, IncludeNode, construct_relative_path
|
||||
|
||||
from django_components.expression import Expression, RuntimeKwargs
|
||||
from django_components.utils import gen_id
|
||||
|
||||
|
||||
class BaseNode(Node):
|
||||
"""Shared behavior for our subclasses of Django's `Node`"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
nodelist: Optional[NodeList] = None,
|
||||
node_id: Optional[str] = None,
|
||||
args: Optional[List[Expression]] = None,
|
||||
kwargs: Optional[RuntimeKwargs] = None,
|
||||
):
|
||||
self.nodelist = nodelist or NodeList()
|
||||
self.node_id = node_id or gen_id()
|
||||
self.args = args or []
|
||||
self.kwargs = kwargs or RuntimeKwargs({})
|
||||
|
||||
|
||||
def nodelist_has_content(nodelist: NodeList) -> bool:
|
||||
for node in nodelist:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue