summaryrefslogtreecommitdiffstats
path: root/examples/playbooks/vars/jinja-spacing.yml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/playbooks/vars/jinja-spacing.yml')
-rw-r--r--examples/playbooks/vars/jinja-spacing.yml41
1 files changed, 41 insertions, 0 deletions
diff --git a/examples/playbooks/vars/jinja-spacing.yml b/examples/playbooks/vars/jinja-spacing.yml
new file mode 100644
index 0000000..419c7bc
--- /dev/null
+++ b/examples/playbooks/vars/jinja-spacing.yml
@@ -0,0 +1,41 @@
+---
+# Should raise jinja[spacing] at line [14, 15, 16, 17, 18, 19, 22, 32, 38], at following variables.
+# ".bad_var_1", ".bad_var_2", ".bad_var_3", ".invalid_multiline_nested_json", ".invalid_nested_json"
+good_var_1: "{{ good_format }}"
+good_var_2: "Value: {{ good_format }}"
+good_var_3: "{{ good_format | filter }}"
+good_var_4: "Value: {{ good_format | filter }}"
+jinja_escape_1: "{{ '{{' }}"
+jinja_escape_2: docker info --format '{{ '{{' }}json .Swarm.LocalNodeState{{ '}}' }}' | tr -d '"'
+jinja_whitespace_control: |
+ {{ good_format }}/
+ {{- good_format }}
+ {{- good_format -}}
+bad_var_1: "{{bad_format}}" # <-- 1
+bad_var_2: "Value: {{ bad_format}}" # <-- 2
+bad_var_3: "{{bad_format }}" # <-- 3
+bad_var_4: "{{ bad_format|filter }}" # <-- 4
+bad_var_5: "Value: {{ bad_format |filter }}" # <-- 5
+bad_var_6: "{{ bad_format| filter }}" # <-- 6
+# spell-checker: disable-next-line
+non_jinja_var: "data = ${lookup{$local_part}lsearch{/etc/aliases}}" # noqa: jinja[spacing]
+json_inside_jinja: "{{ {'test': {'subtest': variable}} }}"
+multiline_vars: # Assert that no false positive on multiline exists
+ cases:
+ case1: >-
+ http://example.com/{{
+ case1 }}
+ case2: >-
+ http://example.com/{{
+ case2 }}
+valid_nested_json: "{{ {'dummy_2': {'nested_dummy_1': 'value_1', 'nested_dummy_2': value_2}} | combine(dummy_1) }}"
+invalid_nested_json: "{{ {'dummy_2': {'nested_dummy_1': 'value_1', 'nested_dummy_2': value_2}} | combine(dummy_1)}}" # <-- 7
+
+valid_multiline_nested_json: >-
+ {{ {'dummy_2': {'nested_dummy_1': value_1,
+ 'nested_dummy_2': value_2}} |
+ combine(dummy_1) }}
+invalid_multiline_nested_json: >- # ignored multiline expression, for now
+ {{ {'dummy_2': {'nested_dummy_1': value_1,
+ 'nested_dummy_2': value_2}} |
+ combine(dummy_1)}}