mirror of
https://github.com/danog/liquid.git
synced 2024-11-27 01:34:41 +01:00
Quote tag names in error messages
This commit is contained in:
parent
6701199fad
commit
2c497e3bbb
@ -99,7 +99,7 @@ func (c Config) parseTokens(tokens []Token) (ASTNode, Error) { // nolint: gocycl
|
||||
}
|
||||
}
|
||||
if bn != nil {
|
||||
return nil, Errorf(bn, "unterminated %s block", bn.Name)
|
||||
return nil, Errorf(bn, "unterminated %q block", bn.Name)
|
||||
}
|
||||
return root, nil
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ func (g blockSyntaxFake) RequiresParent() bool { return g == "else" || g.IsBlock
|
||||
func (g blockSyntaxFake) TagName() string { return string(g) }
|
||||
|
||||
var parseErrorTests = []struct{ in, expected string }{
|
||||
{"{% if test %}", "unterminated if block"},
|
||||
{"{% if test %}", `unterminated "if" block`},
|
||||
{"{% if test %}{% endunless %}", "not inside unless"},
|
||||
// TODO tag syntax could specify statement type to catch these in parser
|
||||
// {"{{ syntax error }}", "parse error"},
|
||||
|
@ -176,10 +176,11 @@ func makeIterator(value interface{}) iterable {
|
||||
case reflect.Array, reflect.Slice:
|
||||
return sliceWrapper(reflect.ValueOf(value))
|
||||
case reflect.Map:
|
||||
rt := reflect.ValueOf(value)
|
||||
array := make([]interface{}, 0, rt.Len())
|
||||
for _, k := range rt.MapKeys() {
|
||||
array = append(array, k.Interface())
|
||||
rv := reflect.ValueOf(value)
|
||||
array := make([][]interface{}, rv.Len())
|
||||
for i, k := range rv.MapKeys() {
|
||||
v := rv.MapIndex(k)
|
||||
array[i] = []interface{}{k.Interface(), v.Interface()}
|
||||
}
|
||||
return sliceWrapper(reflect.ValueOf(array))
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user