mirror of
https://github.com/hanzoai/yaegi.git
synced 2026-10-01 00:49:47 +00:00
When passing a function reference as an interface in a composite binary map, the case should be handled to not take the value of the the node. Related to #886
31 lines
379 B
Go
31 lines
379 B
Go
package main
|
|
|
|
import (
|
|
"html/template"
|
|
)
|
|
|
|
var str = `{{ stringOr .Data "test" }}`
|
|
|
|
func main() {
|
|
_, err := template.New("test").
|
|
Funcs(template.FuncMap{
|
|
"stringOr": stringOr,
|
|
}).
|
|
Parse(str)
|
|
if err != nil {
|
|
println(err.Error())
|
|
return
|
|
}
|
|
println("success")
|
|
}
|
|
|
|
func stringOr(v, def string) string {
|
|
if v == "" {
|
|
return def
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Output:
|
|
// success
|