flosch / pongo2

Django-syntax like template-engine for Go
https://www.schlachter.tech/pongo2
MIT License
2.88k stars 270 forks source link

Add support for operator overloading (e. g. string concatenation using +) #93

Open eatonphil opened 9 years ago

eatonphil commented 9 years ago

Trying to concatenate strings {{var+"@"}} returns 0. Is there a way around this?

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

eatonphil commented 9 years ago

So the answer to this is to use stringformat {{var|stringformat:"%s@"}}. However, this behavior is unexpected. Is it intentional?

flosch commented 9 years ago

It is intentional by now, but could need some improvements, I agree.

gebv commented 8 years ago

{{ "a"|add:"b"|add:"c" }}, i think that's enough.

pierre-b commented 3 years ago

Hi @flosch , would it be possible to add the "~" operator to concatenate strings like jinja2 https://jinja.palletsprojects.com/en/2.11.x/templates/#other-operators ? That would be very helpful! Thank you