Keats / tera

A template engine for Rust based on Jinja2/Django
http://keats.github.io/tera/
MIT License
3.43k stars 279 forks source link

Trying to negate a value fails unexpectedly #871

Open bluenote10 opened 10 months ago

bluenote10 commented 10 months ago

I'm completely new to tera so I may be doing something stupid. I've narrowed the reproduction down to having this macro:

{% macro try_to_negate_value(value) %}
  {{ -value }}
{% endmacro try_to_negate_value %}

and using it like this:

{% import "my_macros" as macros %}
{{ macros::try_to_negate_value(value=42) }}

This panics with

  --> 33:6
   |
33 |   {{ -value }}
   |      ^---
   |
   = expected a value that can be negated or an array of values

When removing the minus sign everything works fine, but I don't understand why 42 cannot be negated. A floating point value doesn't work either.