diff --git a/.gitignore b/.gitignore index e7d3b12862e..321dab6ab4a 100644 --- a/.gitignore +++ b/.gitignore @@ -78,7 +78,6 @@ config/* config/plugins/interactive_environments/**/*.ini config/plugins/**/.cache !config/plugins -!config/templates static/welcome.html.* static/welcome.html static/client_build_hash.txt diff --git a/config/templates/mail/activation-email.html b/lib/galaxy/config/templates/mail/activation-email.html similarity index 100% rename from config/templates/mail/activation-email.html rename to lib/galaxy/config/templates/mail/activation-email.html diff --git a/config/templates/mail/activation-email.txt b/lib/galaxy/config/templates/mail/activation-email.txt similarity index 100% rename from config/templates/mail/activation-email.txt rename to lib/galaxy/config/templates/mail/activation-email.txt diff --git a/lib/galaxy/util/custom_templates/template.py b/lib/galaxy/util/custom_templates/template.py index 310455fa50e..05dfa5cd87b 100644 --- a/lib/galaxy/util/custom_templates/template.py +++ b/lib/galaxy/util/custom_templates/template.py @@ -9,18 +9,23 @@ the Galaxy root (config/templates). import os from jinja2 import Environment -DEFAULT_TEMPLATES_DIR = "config/templates" +DEFAULT_TEMPLATES_DIR = "lib/galaxy/config/templates" TEMPLATE_SEP = '>>>>>>' # Used to split templates into doc/body sections -def render(template_path: str, context: dict, templates_dir: str) -> str: +def render(template_path: str, context: dict, custom_templates_dir: str) -> str: """Read and return templated content as string.""" - with open(_get_template_path(template_path, templates_dir)) as f: - template_str = f.read().split(TEMPLATE_SEP)[-1].split('\n', 1)[1] + with open(_get_template_path(template_path, custom_templates_dir)) as f: + template_str = _get_template_body(f.read()) tmpl = Environment().from_string(template_str) return tmpl.render(**context) +def _get_template_body(template: str) -> str: + """Remove comment/doc header to return the template body.""" + return template.split(TEMPLATE_SEP, 1)[-1].split('\n', 1)[1] + + def _get_template_path(relpath: str, custom_templates_dir: str) -> str: """Return template file path.""" default_path = os.path.join(DEFAULT_TEMPLATES_DIR, relpath)