Hello Experts,
I want to escape '\' in jinja template am using in terraform, I tried multiple ways but somehow it's not happening!
Below is the code snippet :
{%- if mrecords['type'] == "TXT" %}
{%- if mrecords['values'] is defined -%}
{%- set txtrecord_set = namespace(value=[]) -%}
{%- for txtrecord in mrecords['values'] -%}
{%- set txt_value = '"' ~ '\' ~ '"' ~ txtrecord ~ '\' ~ '"' ~ '"' -%}
{%- set txtrecord_set.value = txtrecord_set.value | append(txt_value) -%}
{%- endfor -%}
Error:
Unable to parse statement "if": Unable to parse statement "for": Unable to parse statement "set": Malformed 'set'-tag args. (Line: 63 Col: 66, near "' ~ txtrecord ~ '' ~ '")
Top comments (1)
Hi
Did you try '\' ?
Not sure if it will work but in a lot of cases, you need to double backslash to escape backslash