Skip to content

Commit

Permalink
Allow for a customizable fallback mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
nanuxbe committed Oct 21, 2024
1 parent 89c4952 commit 271c4d9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/dj_angles/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from minestrone import Element

from django.utils.module_loading import import_string

from dj_angles.attributes import Attributes
from dj_angles.mappers.angles import map_angles_include
from dj_angles.mappers.include import map_include
Expand Down Expand Up @@ -92,8 +94,10 @@ def get_django_template_tag(self, slots: Optional[list[tuple[str, Element]]] = N
return f"{django_template_tag}</{wrapping_tag_name}>"

if self.django_template_tag is None:
# Assume any missing template tag is an include
self.django_template_tag = map_include
# Assume any missing template tag should use the fallback mapper
self.django_template_tag = import_string(
get_setting("fallback_mapper", "dj_angles.mappers.include.map_include")
)

# Add component name to the template tags
self.attributes.prepend(self.component_name)
Expand Down

0 comments on commit 271c4d9

Please sign in to comment.