refactor(templatetags): make _RENDERED comment a constant

This commit is contained in:
David Guillot 2022-04-28 23:50:52 +02:00
parent 50a70fc4ba
commit 021339d4a7

View file

@ -15,6 +15,9 @@ from django_components.middleware import (
register = template.Library()
RENDERED_COMMENT_TEMPLATE = "<!-- _RENDERED {name} -->"
def get_components_from_registry(registry):
"""Returns a list unique components from the registry."""
@ -197,7 +200,9 @@ class ComponentNode(Node):
rendered_component = self.component.render(context)
if self.should_render_dependencies:
return (
f"<!-- _RENDERED {self.component._component_name} -->"
RENDERED_COMMENT_TEMPLATE.format(
name=self.component._component_name
)
+ rendered_component
)
else: