forked from Tecnativa/doodba-copier-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_macros.jinja
59 lines (53 loc) · 2.45 KB
/
_macros.jinja
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{# Odoo version formatted without dot #}
{%- macro version_major(odoo_version) %}
{{- "%.0f"|format(odoo_version) }}
{%- endmacro %}
{# Odoo version formatted with one single dot #}
{%- macro version_minor(odoo_version) %}
{{- "%.1f"|format(odoo_version) }}
{%- endmacro %}
{# Loop over domain group lists, and call back with the domain_group variable. #}
{%- macro domains_loop_grouped(domain_groups_list) %}
{%- set domain_group = namespace(exit=false) %}
{%- for _domain_group in domain_groups_list|default([], true) %}
{%- if not domain_group.exit %}
{%- set domain_group.cert_resolver = _domain_group.cert_resolver|default("letsencrypt") %}
{%- set domain_group.entrypoints = _domain_group.entrypoints|default([], true) %}
{%- set domain_group.hosts = _domain_group.hosts|default([], true) %}
{%- set domain_group.path_prefixes = _domain_group.path_prefixes|default([], true) %}
{%- set domain_group.redirect_to = _domain_group.redirect_to|default(none) %}
{%- set domain_group.loop = loop %}
{{- caller(domain_group) }}
{%- endif %}
{%- endfor %}
{%- endmacro %}
{# Loop over domain group lists and call back with a single domain. #}
{%- macro domains_loop_single(domain_groups_list) %}
{%- set domain = namespace(exit=false, index0=0, index=1) %}
{%- set parent_caller = caller %}
{%- call(domain_group) domains_loop_grouped(domain_groups_list) %}
{%- set domain.group = domain_group %}
{%- for host in domain_group.hosts|default([], true) %}
{%- if not domain.exit %}
{%- set domain.host = host %}
{%- set domain.loop = loop %}
{{- parent_caller(domain) }}
{%- set domain.index = domain.index + 1 %}
{%- set domain.index0 = domain.index0 + 1 %}
{%- endif %}
{%- endfor %}
{%- endcall %}
{%- endmacro %}
{# Get the main domain from a domain groups list.
The main domain is the 1st one found from a routing rule that redirects nowhere
and uses no path prefix.
This macro just prints that hostname.
#}
{%- macro first_main_domain(domain_groups_list) %}
{%- call(domain) domains_loop_single(domain_groups_list) %}
{%- if not domain.group.redirect_to and not domain.group.path_prefixes %}
{{- domain.host }}
{%- set domain.exit = true %}
{%- endif %}
{%- endcall %}
{%- endmacro %}