Skip to content

Commit 01c39f7

Browse files
allow for setting location of component directories (#7)
1 parent 6dc47b4 commit 01c39f7

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/django_bird/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
@dataclass
1717
class AppSettings:
18+
COMPONENT_DIRS: list[str] = field(default_factory=lambda: ["bird"])
1819
ENABLE_AUTO_CONFIG: bool = True
1920
_template_configurator: TemplateConfigurator = field(init=False)
2021

src/django_bird/templatetags/django_bird.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
from django.template.base import Parser
99
from django.template.base import Token
1010
from django.template.context import Context
11-
from django.template.loader import render_to_string
11+
from django.template.loader import select_template
1212
from django.utils.safestring import SafeString
1313
from django.utils.safestring import mark_safe
1414

1515
from django_bird._typing import override
16+
from django_bird.conf import app_settings
1617

1718
register = template.Library()
1819

@@ -61,7 +62,11 @@ def render(self, context: Context) -> SafeString:
6162
},
6263
}
6364

64-
return render_to_string(f"bird/{self.name}.html", component_context)
65+
template_names = [
66+
f"{directory}/{self.name}.html" for directory in app_settings.COMPONENT_DIRS
67+
]
68+
template = select_template(template_names)
69+
return template.render(component_context)
6570

6671
def render_slots(self, context: Context) -> dict[str, str]:
6772
if self.nodelist is None:

0 commit comments

Comments
 (0)