pongo2 icon indicating copy to clipboard operation
pongo2 copied to clipboard

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

Open eatonphil opened this issue 9 years ago • 4 comments

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 avatar Aug 11 '15 02:08 eatonphil

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

eatonphil avatar Aug 11 '15 02:08 eatonphil

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

flosch avatar Aug 24 '15 23:08 flosch

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

gebv avatar Jun 17 '16 15:06 gebv

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

pierre-b avatar Nov 26 '20 17:11 pierre-b