Fix Python – Convert integer to string Jinja

Question

Asked By – Glen Swift

I have an integer

{% set curYear = 2013 %}

In {% if %} statement I have to compare it with some string. I can’t set curYear to string at the beginning because I have to decrement it in loop.

How can I convert it?

Now we will see solution for issue: Convert integer to string Jinja


Answer

I found the answer.

Cast integer to string:

myOldIntValue|string

Cast string to integer:

myOldStrValue|int

This question is answered By – Glen Swift

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0