Skip to content

Commit 77dfe53

Browse files
committed
feat: allow projects to create their own ASCIIDOC templates
1 parent 6b09751 commit 77dfe53

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

scripts/generators/asciidoc_fields.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,14 @@ def save_asciidoc(f, text):
140140

141141
# jinja2 setup
142142

143-
143+
cur_dir = path.abspath(path.curdir)
144144
local_dir = path.dirname(path.abspath(__file__))
145-
TEMPLATE_DIR = path.join(local_dir, '../templates')
145+
CUR_TEMPLATE_DIR = path.join(cur_dir, 'templates')
146+
LOCAL_TEMPLATE_DIR = path.join(local_dir, '../templates')
147+
if path.exists(CUR_TEMPLATE_DIR):
148+
TEMPLATE_DIR=CUR_TEMPLATE_DIR
149+
elif path.exists(LOCAL_TEMPLATE_DIR):
150+
TEMPLATE_DIR=LOCAL_TEMPLATE_DIR
146151
template_loader = jinja2.FileSystemLoader(searchpath=TEMPLATE_DIR)
147152
template_env = jinja2.Environment(loader=template_loader, keep_trailing_newline=True)
148153

0 commit comments

Comments
 (0)