jinja: correct member access rule (#18905)
This commit is contained in:
parent
d1b4757ded
commit
f55b033ae6
5 changed files with 37 additions and 2 deletions
|
|
@ -1063,6 +1063,18 @@ static void test_object_methods(testing & t) {
|
|||
{{"obj", {{"items", json::array({1, 2, 3})}}}},
|
||||
"{\"items\": [1, 2, 3]}"
|
||||
);
|
||||
|
||||
test_template(t, "object attribute and key access",
|
||||
"{{ obj.keys()|join(',') }} vs {{ obj['keys'] }} vs {{ obj.test }}",
|
||||
{{"obj", {{"keys", "value"}, {"test", "attr_value"}}}},
|
||||
"keys,test vs value vs attr_value"
|
||||
);
|
||||
|
||||
test_template(t, "env should not have object methods",
|
||||
"{{ keys is undefined }} {{ obj.keys is defined }}",
|
||||
{{"obj", {{"a", "b"}}}},
|
||||
"True True"
|
||||
);
|
||||
}
|
||||
|
||||
static void test_template(testing & t, const std::string & name, const std::string & tmpl, const json & vars, const std::string & expect) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue