Skip to content

Commit 46968b0

Browse files
committed
feat: allow projects to create their own ASCIIDOC templates
1 parent 1ef397e commit 46968b0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

scripts/generators/asciidoc_fields.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,14 @@ def save_asciidoc(f, text):
141141
# jinja2 setup
142142

143143

144+
cur_dir = path.abspath(path.curdir)
144145
local_dir = path.dirname(path.abspath(__file__))
145-
TEMPLATE_DIR = path.join(local_dir, '../templates')
146+
CUR_TEMPLATE_DIR = path.join(cur_dir, 'templates')
147+
LOCAL_TEMPLATE_DIR = path.join(local_dir, '../templates')
148+
if path.exists(CUR_TEMPLATE_DIR):
149+
TEMPLATE_DIR = CUR_TEMPLATE_DIR
150+
elif path.exists(LOCAL_TEMPLATE_DIR):
151+
TEMPLATE_DIR = LOCAL_TEMPLATE_DIR
146152
template_loader = jinja2.FileSystemLoader(searchpath=TEMPLATE_DIR)
147153
template_env = jinja2.Environment(loader=template_loader, keep_trailing_newline=True)
148154

0 commit comments

Comments
 (0)