Skip to content

Commit 92b3ce1

Browse files
committed
basic template customisation
1 parent 568677b commit 92b3ce1

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/openapi_python_generator/language_converters/python/jinja_config.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import os
12
from pathlib import Path
23

34
from jinja2 import Environment
4-
from jinja2 import FileSystemLoader
5+
from jinja2 import FileSystemLoader, ChoiceLoader
56

67

78
ENUM_TEMPLATE = "enum.jinja2"
@@ -12,5 +13,16 @@
1213
TEMPLATE_PATH = Path(__file__).parent / "templates"
1314

1415
JINJA_ENV = Environment(
15-
loader=FileSystemLoader(TEMPLATE_PATH), autoescape=True, trim_blocks=True
16+
loader=(
17+
ChoiceLoader(
18+
[
19+
FileSystemLoader(os.environ["CUSTOM_TEMPLATE_PATH"]),
20+
FileSystemLoader(TEMPLATE_PATH),
21+
]
22+
)
23+
if os.environ.get("CUSTOM_TEMPLATE_PATH")
24+
else FileSystemLoader(TEMPLATE_PATH)
25+
),
26+
autoescape=True,
27+
trim_blocks=True,
1628
)

0 commit comments

Comments
 (0)