# when statements should not include jinja2 templating delimiters

**URL:** <https://forum.ansible.com/t/when-statements-should-not-include-jinja2-templating-delimiters/24694>\
**Category:** Ansible Project\
**Created:** [June 10, 2017, 2:39am UTC](https://forum.ansible.com/t/when-statements-should-not-include-jinja2-templating-delimiters/24694 "2017-06-10T02:39:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_Catie](https://avatars.discourse-cdn.com/v4/letter/_/e8c25b/32.png) [@\_Catie](https://forum.ansible.com/u/_Catie)\
**Post date:** [June 10, 2017, 2:39am UTC](https://forum.ansible.com/t/when-statements-should-not-include-jinja2-templating-delimiters/24694/1 "2017-06-10T02:39:34Z")

</div>

Hi,

I ran into this warning with different scenario:

For example,I have a registered variable “ **command\_result** ” from previous command result. Also, I have a variable “ **num** ”, which is a number. I want to use when statement to compare if the value of **command\_result.stdout** equals **num** in string. For example, command\_result.stdout is “1”, and num is 1. How can I write the when statement?

Thank you in advance,  
Catie

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [June 12, 2017, 4:29pm UTC](https://forum.ansible.com/t/when-statements-should-not-include-jinja2-templating-delimiters/24694/2 "2017-06-12T16:29:17Z")

</div>

If you have showed us the when statement you are using today it would be easier to understand what you are trying to do.  
But I think you are looking for something like this.

&nbsp;&nbsp;&nbsp;when: command\_result.stdout == num | string

or

&nbsp;&nbsp;&nbsp;when: command\_result.stdout | int == num

---

<div class="post-metadata">

**Author:** ![\_Catie](https://avatars.discourse-cdn.com/v4/letter/_/e8c25b/32.png) [@\_Catie](https://forum.ansible.com/u/_Catie)\
**Post date:** [June 12, 2017, 4:32pm UTC](https://forum.ansible.com/t/when-statements-should-not-include-jinja2-templating-delimiters/24694/3 "2017-06-12T16:32:27Z")

</div>

Thank you, Kai. I think converting types what I am looking for.

Best,  
Catie
