# Ultimate way to escape braces? (strange corner case inside)

**URL:** <https://forum.ansible.com/t/ultimate-way-to-escape-braces-strange-corner-case-inside/19433>\
**Category:** Ansible Project\
**Created:** [October 4, 2015, 3:11pm UTC](https://forum.ansible.com/t/ultimate-way-to-escape-braces-strange-corner-case-inside/19433 "2015-10-04T15:11:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrei\_Pashkin](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@Andrei\_Pashkin](https://forum.ansible.com/u/Andrei_Pashkin)\
**Post date:** [October 4, 2015, 3:11pm UTC](https://forum.ansible.com/t/ultimate-way-to-escape-braces-strange-corner-case-inside/19433/1 "2015-10-04T15:11:18Z")

</div>

With Ansible 1.9.2 and this playbook:

> `---`  
> `- name: test`  
> `� hosts: localhost`  
> `� connection: local`  
> `� tasks:`  
> `��� - name: register variable`  
> `����� shell: >`  
> `������� echo {% raw %} '{{ .Suddenly.Go.Template.String }}' {% endraw %}`  
> `����� register: var`  
> `��� - debug:`  
> `������� var: var`

After invoking like it: `ansible-playbook test.yml`  
You will get this:

> `fatal: [localhost] => Failed to template {{var}}: Failed to template echo '{{ .Suddenly.Go.Template.String }}': template error while templating string: unexpected '.'`

I actually barely understand, why it may happen. Seems like Ansible renders `var` twicely, and in a second pass it cannot parse Go template string. Or I’m doing something wrong?

---

<div class="post-metadata">

**Author:** ![Borys\_Borysenko](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@Borys\_Borysenko](https://forum.ansible.com/u/Borys_Borysenko)\
**Post date:** [October 4, 2015, 8:12pm UTC](https://forum.ansible.com/t/ultimate-way-to-escape-braces-strange-corner-case-inside/19433/2 "2015-10-04T20:12:16Z")

</div>

The \*\*.\*\*Suddenly.Go.Template.String is not valid Ansible variable name. Take a look on “What Makes A Valid Variable Name” section of Ansible documentation.

> it cannot parse Go template string

I suppose it just typo, but to be clear Ansible support only jinja2 template language.

---

<div class="post-metadata">

**Author:** ![Andrei\_Pashkin](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@Andrei\_Pashkin](https://forum.ansible.com/u/Andrei_Pashkin)\
**Post date:** [October 5, 2015, 10:47am UTC](https://forum.ansible.com/t/ultimate-way-to-escape-braces-strange-corner-case-inside/19433/3 "2015-10-05T10:47:58Z")

</div>

The Go template part is not expected to be parsed by Ansible’s template engine at all, and it’s enclosed in `{% raw %}...{``% endraw %}` tag because of that.

---

<div class="post-metadata">

**Author:** ![Borys\_Borysenko](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@Borys\_Borysenko](https://forum.ansible.com/u/Borys_Borysenko)\
**Post date:** [October 5, 2015, 11:49am UTC](https://forum.ansible.com/t/ultimate-way-to-escape-braces-strange-corner-case-inside/19433/4 "2015-10-05T11:49:57Z")

</div>

Hi Andrew, now it’s more clear. I did not realize what you want to achieve at first. According to the [Jinja docs](http://jinja.pocoo.org/docs/dev/templates/#escaping) it should work:

shell: \>  
echo {% raw %} {{ ‘{{.Suddenly.Go.Template.String }}’ }} {% endraw %} \> /tmp/test
