mirror of
https://github.com/django-components/django-components.git
synced 2025-08-11 09:48:00 +00:00
feat: TagFormatter - Allow users to customize component template tags (#572)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
b89c09aa5f
commit
71d8679e8d
23 changed files with 1593 additions and 474 deletions
|
@ -1,8 +1,11 @@
|
|||
from enum import Enum
|
||||
from typing import Dict, List
|
||||
from typing import TYPE_CHECKING, Dict, List, Union
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django_components.tag_formatter import TagFormatterABC
|
||||
|
||||
|
||||
class ContextBehavior(str, Enum):
|
||||
DJANGO = "django"
|
||||
|
@ -115,5 +118,9 @@ class AppSettings:
|
|||
valid_values = [behavior.value for behavior in ContextBehavior]
|
||||
raise ValueError(f"Invalid context behavior: {raw_value}. Valid options are {valid_values}")
|
||||
|
||||
@property
|
||||
def TAG_FORMATTER(self) -> Union["TagFormatterABC", str]:
|
||||
return self.settings.get("tag_formatter", "django_components.component_formatter")
|
||||
|
||||
|
||||
app_settings = AppSettings()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue