Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TEMPLATE/_mapdata/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
---
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split("/")[0] %}
{%- from tplroot ~ "/map.jinja" import mapdata with context %}
{%- from tplroot ~ "/map.jinja" import mapdata without context %}
{%- set _mapdata = {
"values": mapdata,
Expand Down
2 changes: 1 addition & 1 deletion TEMPLATE/config/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE with context %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE without context %}
include:
- {{ sls_service_clean }}
Expand Down
2 changes: 1 addition & 1 deletion TEMPLATE/config/file.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_package_install = tplroot ~ '.package.install' %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE with context %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE without context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}

include:
Expand Down
13 changes: 11 additions & 2 deletions TEMPLATE/libmapstack.jinja
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
{#- -*- coding: utf-8 -*- #}
{#- vim: ft=jinja #}

{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split("/")[0] %}
{%- if not tplfile.endswith("/libmapstack.jinja") %}
{#- Force import `without context` #}
{#- `with context` override the `tplfile` and `tpldir` variables #}
{{- raise("Import error: libmapstack.jinja must be imported without context. tplfile='" ~ tplfile ~ "'") }}
{%- elif tplfile.startswith("../") %}
{#- Force import with absolute path #}
{{- raise("Import error: libmapstack.jinja must be imported with absolute path. tplfile='" ~ tplfile ~ "'") }}
{%- endif %}

{#- `tplroot` is the directory of the current imported file #}
{%- set tplroot = tpldir %}
{%- from tplroot ~ "/libmatchers.jinja" import parse_matchers, query_map %}

{%- set _default_config_dirs = [
Expand Down
11 changes: 10 additions & 1 deletion TEMPLATE/libmatchers.jinja
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
{#- -*- coding: utf-8 -*- #}
{#- vim: ft=jinja #}

{%- if not tplfile.endswith("/libmatchers.jinja") %}
{#- Force import `without context` #}
{#- `with context` override the `tplfile` and `tpldir` variables #}
{{- raise("Import error: libmatchers.jinja must be imported without context. tplfile='" ~ tplfile ~ "'") }}
{%- elif tplfile.startswith("../") %}
{#- Force import with absolute path #}
{{- raise("Import error: libmatchers.jinja must be imported with absolute path. tplfile='" ~ tplfile ~ "'") }}
{%- endif %}

{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split("/")[0] %}
{%- set tplroot = tpldir %}
{%- from tplroot ~ "/libsaltcli.jinja" import cli %}

{%- set query_map = {
Expand Down
19 changes: 14 additions & 5 deletions TEMPLATE/map.jinja
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# -*- coding: utf-8 -*-
# vim: ft=jinja
{#- -*- coding: utf-8 -*- #}
{#- vim: ft=jinja #}

{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split("/")[0] %}
{%- from tplroot ~ "/libmapstack.jinja" import mapstack %}
{%- if not tplfile.endswith("/map.jinja") %}
{#- Force import `without context` #}
{#- `with context` override the `tplfile` and `tpldir` variables #}
{{- raise("Import error: map.jinja must be imported without context. tplfile='" ~ tplfile ~ "'") }}
{%- elif tplfile.startswith("../") %}
{#- Force import with absolute path #}
{{- raise("Import error: map.jinja must be imported with absolute path. tplfile='" ~ tplfile ~ "'") }}
{%- endif %}

{#- `tplroot` is the directory of the current imported file #}
{%- set tplroot = tpldir %}
{%- from tplroot ~ "/libmapstack.jinja" import mapstack without context %}

{#- Where to lookup parameters source files #}
{%- set formula_param_dir = tplroot ~ "/parameters" %}
Expand Down
2 changes: 1 addition & 1 deletion TEMPLATE/package/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_config_clean = tplroot ~ '.config.clean' %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE with context %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE without context %}
include:
- {{ sls_config_clean }}
Expand Down
2 changes: 1 addition & 1 deletion TEMPLATE/package/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE with context %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE without context %}
TEMPLATE-package-install-pkg-installed:
pkg.installed:
Expand Down
2 changes: 1 addition & 1 deletion TEMPLATE/service/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE with context %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE without context %}
TEMPLATE-service-clean-service-dead:
service.dead:
Expand Down
2 changes: 1 addition & 1 deletion TEMPLATE/service/running.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_config_file = tplroot ~ '.config.file' %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE with context %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE without context %}
include:
- {{ sls_config_file }}
Expand Down
2 changes: 1 addition & 1 deletion TEMPLATE/subcomponent/config/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE with context %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE without context %}
include:
- {{ sls_service_clean }}
Expand Down
2 changes: 1 addition & 1 deletion TEMPLATE/subcomponent/config/file.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_config_file = tplroot ~ '.config.file' %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE with context %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE without context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}

include:
Expand Down
4 changes: 2 additions & 2 deletions docs/map.jinja.rst
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ Here is the best way to use it in an ``sls`` file:

{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split("/")[0] %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE with context %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE without context %}

test-does-nothing-but-display-TEMPLATE-as-json:
test.nop:
Expand All @@ -480,7 +480,7 @@ Here is an example based on `template-formula/TEMPLATE/config/file.sls`_:
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_package_install = tplroot ~ '.package.install' %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE with context %}
{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE without context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}

include:
Expand Down