1
0
mirror of https://github.com/danog/liquid.git synced 2024-11-26 23:24:38 +01:00

Quote tag names in error messages

This commit is contained in:
Oliver Steele 2017-07-17 12:19:14 -04:00
parent 6701199fad
commit 2c497e3bbb
3 changed files with 7 additions and 6 deletions

View File

@ -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
}

View File

@ -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"},

View File

@ -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: