-
-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathpongo2_issues_test.go
45 lines (37 loc) · 902 Bytes
/
pongo2_issues_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package pongo2_test
import (
"testing"
"github.com/flosch/pongo2/v6"
)
func TestIssue151(t *testing.T) {
tpl, err := pongo2.FromString("{{ mydict.51232_3 }}{{ 12345_123}}{{ 995189baz }}")
if err != nil {
t.Fatal(err)
}
str, err := tpl.Execute(pongo2.Context{
"mydict": map[string]string{
"51232_3": "foo",
},
"12345_123": "bar",
"995189baz": "baz",
})
if err != nil {
t.Fatal(err)
}
if str != "foobarbaz" {
t.Fatalf("Expected output 'foobarbaz', but got '%s'.", str)
}
}
func TestIssue297(t *testing.T) {
tpl, err := pongo2.FromString("Testing: {{ input|wordwrap:4 }}!")
if err != nil {
t.Fatal(err)
}
str, err := tpl.Execute(pongo2.Context{"input": "one two three four five six"})
if err != nil {
t.Fatal(err)
}
if str != "Testing: one two three four\nfive six!" {
t.Fatalf("Expected `Testing: one two three four\nfive six!`, but got `%v`.", str)
}
}