mirror of
https://github.com/danog/liquid.git
synced 2024-11-27 04:35:14 +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 {
|
if bn != nil {
|
||||||
return nil, Errorf(bn, "unterminated %s block", bn.Name)
|
return nil, Errorf(bn, "unterminated %q block", bn.Name)
|
||||||
}
|
}
|
||||||
return root, nil
|
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) }
|
func (g blockSyntaxFake) TagName() string { return string(g) }
|
||||||
|
|
||||||
var parseErrorTests = []struct{ in, expected string }{
|
var parseErrorTests = []struct{ in, expected string }{
|
||||||
{"{% if test %}", "unterminated if block"},
|
{"{% if test %}", `unterminated "if" block`},
|
||||||
{"{% if test %}{% endunless %}", "not inside unless"},
|
{"{% if test %}{% endunless %}", "not inside unless"},
|
||||||
// TODO tag syntax could specify statement type to catch these in parser
|
// TODO tag syntax could specify statement type to catch these in parser
|
||||||
// {"{{ syntax error }}", "parse error"},
|
// {"{{ syntax error }}", "parse error"},
|
||||||
|
@ -176,10 +176,11 @@ func makeIterator(value interface{}) iterable {
|
|||||||
case reflect.Array, reflect.Slice:
|
case reflect.Array, reflect.Slice:
|
||||||
return sliceWrapper(reflect.ValueOf(value))
|
return sliceWrapper(reflect.ValueOf(value))
|
||||||
case reflect.Map:
|
case reflect.Map:
|
||||||
rt := reflect.ValueOf(value)
|
rv := reflect.ValueOf(value)
|
||||||
array := make([]interface{}, 0, rt.Len())
|
array := make([][]interface{}, rv.Len())
|
||||||
for _, k := range rt.MapKeys() {
|
for i, k := range rv.MapKeys() {
|
||||||
array = append(array, k.Interface())
|
v := rv.MapIndex(k)
|
||||||
|
array[i] = []interface{}{k.Interface(), v.Interface()}
|
||||||
}
|
}
|
||||||
return sliceWrapper(reflect.ValueOf(array))
|
return sliceWrapper(reflect.ValueOf(array))
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user