Jinja2==2.7.1μ μ¬μ©νκ³ μμ΅λλ€.
In [2]: t = jinja2.Template("{{ x/2 | round }}") #does not work?
In [3]: t
Out[3]: <Template memory:161e910>
In [4]: t.render(x=7)
Out[4]: u'3.5'
In [5]: t2 = jinja2.Template("{{ x | float }}") # float works
In [6]: t2.render(x=3)
Out[6]: u'3.0'
In [12]: t3 = Template("{{ x / 2 | int }}") # does not work
In [13]: t3.render(x=7)
Out[13]: u'3.5'
λ΄ μΆμΈ‘μΌλ‘λ μ°μ°μ μ°μ μμκ° λ κ²μ
λλ€. x/2 | round
λ x / (2 | round)
λ‘ κ΅¬λ¬Έ λΆμλ©λλ€.
κ·Έλ λ€κ° λ§μ,
κ°μ¬ ν΄μ
In [6]: t = jinja2.Template("{{ (x/2) | int }}")
In [7]: t.render(x=5)
Out[7]: u'2'
μ΄κ²κ³Ό κ΄λ ¨μ΄ μλ κ² κ°μ΅λλ€. https://github.com/mitsuhiko/jinja2/issues/119
μ νν λ¬Έμ κ° λ°μνμ΅λλ€!
@hvnsweeting λ° @Naddiseo κ°μ¬ν©λλ€.
λμΌν λ¬Έμ , λμΌν μ루μ
. μ κ²½μ°μλ ν μ΄μμ€ν΄νΈμμ λ€μκ³Ό κ°μ κ²°κ³Όλ₯Ό μ»μμ΅λλ€.
{{ ((states.input_number.guestroom_setpoint_shift.state | float) * 2) | int }}
κ°μ¬ ν΄μ!
κ°μ₯ μ μ©ν λκΈ
λ΄ μΆμΈ‘μΌλ‘λ μ°μ°μ μ°μ μμκ° λ κ²μ λλ€.
x/2 | round
λx / (2 | round)
λ‘ κ΅¬λ¬Έ λΆμλ©λλ€.