flosch / pongo2

Django-syntax like template-engine for Go
https://www.schlachter.tech/pongo2
MIT License
2.87k stars 270 forks source link

Can nested var supported? #304

Closed iyaozhen closed 2 years ago

iyaozhen commented 2 years ago

Demo

context := map[string]any{
    "map1":  map[string]string{"key1": "value1", "key2": "value2"},
    "var2":  "key1",
}

{{map1.{{var2}}}} fail, error = [Error (where: parser) in | Line 1 Col 8 near '{{'] This token is not allowed within a variable name

{{map1.var2}} got = , want value1

flosch commented 2 years ago

Try map1[var2].

flosch commented 2 years ago

Try ‘map1[var2]’, this should work.

Yao Zhen @.***> schrieb am Fr. 8. Juli 2022 um 14:26:

Demo

context := map[string]any{ "map1": map[string]string{"key1": "value1", "key2": "value2"}, "var2": "key1", }

{{map1.{{var2}}}} fail, error = [Error (where: parser) in | Line 1 Col 8 near '{{'] This token is not allowed within a variable name

{{map1.var2}} got = , want value1

— Reply to this email directly, view it on GitHub https://github.com/flosch/pongo2/issues/304, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAEWIDGHHPHNJDRRA5L2VDVTAM7LANCNFSM53A2SQHA . You are receiving this because you are subscribed to this thread.Message ID: @.***>