tyler-sommer / stick

A golang port of the Twig templating engine
MIT License
183 stars 36 forks source link

OR operator evaluation bug #30

Closed mingwho closed 4 years ago

mingwho commented 4 years ago

Hi Tyler it's me again :) It seems like if {% if true or false %} returns false For example:

package main

import (
    "os"
    "github.com/tyler-sommer/stick"
)

func main() {
    env := stick.New(nil);    // A nil loader means stick will simply execute
                          // the string passed into env.Execute.

// Templates receive a map of string to any value.
p := map[string]stick.Value{"name": "World"}

// Substitute os.Stdout with any io.Writer.
env.Execute(`{% set item1 = "orange" %} {% set item2 = "apple" %} {% if item1 == "banana" or item2 == "apple" %} At least one item is correct {% else %} neither item is correct {% endif %}`, os.Stdout, p)
}

It will print neither item is correct. I will have a look into this as well :)

tyler-sommer commented 4 years ago

Thanks for pointing this out, @mingwho ! It turned out to be a silly mistake on my part, and easily fixed in #31. Cheers!

mingwho commented 4 years ago

Thanks @tyler-sommer !