Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to subtract #289

Open
daemocles opened this issue Feb 12, 2022 · 0 comments
Open

Unable to subtract #289

daemocles opened this issue Feb 12, 2022 · 0 comments

Comments

@daemocles
Copy link

I am trying to subtract an integer by 1 with the add filter, however there seems to be an issue with parsing negative integers

package main
import (
        "fmt"
        "github.com/flosch/pongo2/v5"
)
func main() {
        template, err := pongo2.FromString("{{ variable|add:-1 }}")
        if err != nil {
                panic(err)
        }
        context := pongo2.Context{"variable": 5}
        out, err := template.Execute(context)
        if err != nil {
                panic(err)
        }
        fmt.Println(out)
}

However, I get the following error:
panic: [Error (where: parser) in <string> | Line 1 Col 17 near '-'] Expected either a number, string, keyword or identifier.

Also, adding quotes around the -1 ends up appending a -1 string at the end of my variable instead of actually subtracting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants