mirror of
https://github.com/danog/liquid.git
synced 2024-11-26 22:34:44 +01:00
parent
c94902613d
commit
f670bfcb13
@ -35,3 +35,31 @@ func TestEngine_ParseAndRenderString(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngine_ParseAndRenderString_ptr_to_hash(t *testing.T) {
|
||||
params := map[string]interface{}{
|
||||
"message": &map[string]interface{}{
|
||||
"Text": "hello",
|
||||
},
|
||||
}
|
||||
engine := NewEngine()
|
||||
template := "{{ message.Text }}"
|
||||
str, err := engine.ParseAndRenderString(template, params)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "hello", str)
|
||||
}
|
||||
|
||||
type testStruct struct{ Text string }
|
||||
|
||||
func TestEngine_ParseAndRenderString_struct(t *testing.T) {
|
||||
params := map[string]interface{}{
|
||||
"message": testStruct{
|
||||
Text: "hello",
|
||||
},
|
||||
}
|
||||
engine := NewEngine()
|
||||
template := "{{ message.Text }}"
|
||||
str, err := engine.ParseAndRenderString(template, params)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "hello", str)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user