# Jinja2 template directives

**URL:** <https://forum.ansible.com/t/jinja2-template-directives/15596>\
**Category:** Ansible Project\
**Created:** [July 3, 2014, 12:03am UTC](https://forum.ansible.com/t/jinja2-template-directives/15596 "2014-07-03T00:03:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Henry\_Finucane](https://avatars.discourse-cdn.com/v4/letter/h/94ad74/32.png) [@Henry\_Finucane](https://forum.ansible.com/u/Henry_Finucane)\
**Post date:** [July 3, 2014, 12:03am UTC](https://forum.ansible.com/t/jinja2-template-directives/15596/1 "2014-07-03T00:03:04Z")

</div>

Howdy,  
One of the changes to 1.6.6 dropped support for jinja2 template  
directives: [https://github.com/ansible/ansible/commit/3761bc113295e20771544491d007f1d328f40b99](https://github.com/ansible/ansible/commit/3761bc113295e20771544491d007f1d328f40b99)

I'd been leaning on that pretty heavily to convert a project to  
Ansible, and I'm not really looking forward to auditing a couple  
hundred templates. Is there a different way to disable trim\_blocks?

Cheers,

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 3, 2014, 12:18am UTC](https://forum.ansible.com/t/jinja2-template-directives/15596/2 "2014-07-03T00:18:00Z")

</div>

Yes, they did, and this was unfortunate.

This was a fix to prevent nodes from returning facts that contain Jinja2 expressions (which long story short could result in some hijinx), and because the filter choices are made in the template here, we had to remove the feature for allowing the block delimiters like {{ and {% to be changed in order to reliably filter these out.

Now, I think what we should probably do (it would have to be on the devel branch) is make this option _ONLY_ be able to set trim\_blocks (and maybe another whitelist of certain options).

Is this something you might like to take a crack at?

trim\_blocks themselves was never a problem.

---

<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:** [July 3, 2014, 12:30am UTC](https://forum.ansible.com/t/jinja2-template-directives/15596/3 "2014-07-03T00:30:16Z")

</div>

The end/start block functionality is very useful, I’m thinking it could be made ‘safe’ by ‘re cleaning’ the data if they get changed on override. I have the patch 1/2 done in my head, I should be able to tackle it this weekend if this approach is acceptable.  
​

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 3, 2014, 1:03am UTC](https://forum.ansible.com/t/jinja2-template-directives/15596/4 "2014-07-03T01:03:13Z")

</div>

Would totally be open to looking at it…

---

<div class="post-metadata">

**Author:** ![Henry\_Finucane](https://avatars.discourse-cdn.com/v4/letter/h/94ad74/32.png) [@Henry\_Finucane](https://forum.ansible.com/u/Henry_Finucane)\
**Post date:** [July 3, 2014, 4:27am UTC](https://forum.ansible.com/t/jinja2-template-directives/15596/5 "2014-07-03T04:27:33Z")

</div>

Yes: [https://github.com/ansible/ansible/pull/8026](https://github.com/ansible/ansible/pull/8026)

It doesn’t raise an error for settings Ansible no longer supports, primarily because I couldn’t figure out the plumbing. But it is a whitelist, and it does work, so there’s that.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 3, 2014, 12:31pm UTC](https://forum.ansible.com/t/jinja2-template-directives/15596/6 "2014-07-03T12:31:33Z")

</div>

I’ve merged this now on devel for people that need this feature. We’re open to expanding the whitelist if needed, and will also see what Brian comes up with in terms of upgrades.

Thanks!
