jinja: correct member access rule (#18905)
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user