# bug?  Ignoring jinja variable substitution in templates

**URL:** <https://forum.ansible.com/t/bug-ignoring-jinja-variable-substitution-in-templates/13736>\
**Category:** Ansible Project\
**Created:** [October 21, 2013, 7:29pm UTC](https://forum.ansible.com/t/bug-ignoring-jinja-variable-substitution-in-templates/13736 "2013-10-21T19:29:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brice\_Burgess](https://avatars.discourse-cdn.com/v4/letter/b/d2c977/32.png) [@Brice\_Burgess](https://forum.ansible.com/u/Brice_Burgess)\
**Post date:** [October 21, 2013, 7:29pm UTC](https://forum.ansible.com/t/bug-ignoring-jinja-variable-substitution-in-templates/13736/1 "2013-10-21T19:29:38Z")

</div>

Is it possible to ignore variable substitution in templates? I’ve attempted {% raw %}, {% verbatim %}, slash escaping, and using jinja to output braces.

Reason: I am writing a playbook that generates playbooks; so need to preserve the curly braces. Here’s an example:

\<mytemplate.j2\>

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [October 21, 2013, 7:40pm UTC](https://forum.ansible.com/t/bug-ignoring-jinja-variable-substitution-in-templates/13736/2 "2013-10-21T19:40:47Z")

</div>

you can add an override header (small notice on template docs that is on my  
list to expand)  
make this the first line of the template:  
#jinja2: variable\_start\_string: "[%" , variable\_end\_string: "%]"

then you can use [% var %] on the 'outer' template and {{ var }} won't get  
touched in the 'inner' template.

---

<div class="post-metadata">

**Author:** ![Brice\_Burgess](https://avatars.discourse-cdn.com/v4/letter/b/d2c977/32.png) [@Brice\_Burgess](https://forum.ansible.com/u/Brice_Burgess)\
**Post date:** [October 21, 2013, 9:30pm UTC](https://forum.ansible.com/t/bug-ignoring-jinja-variable-substitution-in-templates/13736/3 "2013-10-21T21:30:17Z")

</div>

Brian,

Thanks for the workaround! I saw mention of this && didn’t think to apply. Do you think supporting {% raw %} is worthwhile? I can open a ticket if so.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [October 22, 2013, 1:23am UTC](https://forum.ansible.com/t/bug-ignoring-jinja-variable-substitution-in-templates/13736/4 "2013-10-22T01:23:44Z")

</div>

raw is standard Jinja2, we didn’t do anything to disable it.

---

<div class="post-metadata">

**Author:** ![Brice\_Burgess](https://avatars.discourse-cdn.com/v4/letter/b/d2c977/32.png) [@Brice\_Burgess](https://forum.ansible.com/u/Brice_Burgess)\
**Post date:** [October 24, 2013, 7:17pm UTC](https://forum.ansible.com/t/bug-ignoring-jinja-variable-substitution-in-templates/13736/5 "2013-10-24T19:17:02Z")

</div>

Brian,

I have tried this workaround. Unfortunately curly braces STILL get evaluated. E.g. in the following template

\<mytemplate.j2\>  
#jinja2: variable\_start\_string: “[%” , variable\_end\_string: “%]”

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [October 25, 2013, 11:39pm UTC](https://forum.ansible.com/t/bug-ignoring-jinja-variable-substitution-in-templates/13736/6 "2013-10-25T23:39:03Z")

</div>

Thanks for the ticket. It’s in queue!
