Skip to content

Commit edaf651

Browse files
committed
Support for multiple directories
1 parent 1e90971 commit edaf651

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

flask_mako.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,20 @@ def _create_lookup(app):
184184
'default_filters': app.config['MAKO_DEFAULT_FILTERS'],
185185
'preprocessor': app.config['MAKO_PREPROCESSOR'],
186186
}
187-
path = os.path.join(app.root_path, app.template_folder)
188-
paths = [path]
187+
if isinstance(app.template_folder, (list, tuple)):
188+
paths = [os.path.join(app.root_path, tf) for tf in app.template_folder]
189+
else:
190+
paths = [os.path.join(app.root_path, app.template_folder)]
189191
blueprints = getattr(app, 'blueprints', {})
190192
for blueprint in itervalues(blueprints):
191-
if blueprint.template_folder:
192-
blueprint_template_path = os.path.join(blueprint.root_path,
193-
blueprint.template_folder)
194-
if os.path.isdir(blueprint_template_path):
195-
paths.append(blueprint_template_path)
193+
bp_tf = blueprint.template_folder
194+
if bp_tf:
195+
if isinstance(bp_tf, (list, tuple)):
196+
paths.extend([os.path.join(blueprint.root_path, tf)
197+
for tf in bp_tf])
198+
else:
199+
paths.append(os.path.join(blueprint.root_path, bp_tf))
200+
paths = [path for path in paths if os.path.isdir(path)]
196201
return TemplateLookup(directories=paths, **kw)
197202

198203

0 commit comments

Comments
 (0)