Changes between Version 2 and Version 3 of Ticket #35735
- Timestamp:
- Sep 5, 2024, 12:59:31 PM (3 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #35735
- Property Has patch set
-
Ticket #35735 – Description
v2 v3 6 6 you could access the class property in the template through (if it was returned by a callable) `{{ get_my_class.in_template }}`. 7 7 8 The template system first checks if the class is subscriptable (i.e. tries `context_value["in_template"]`), will fail and then will get the in_template property.8 The template system first executes the callable `get_my_class` which we assume returns `MyClass`. Then it checks if the class is subscriptable (i.e. tries `MyClass["in_template"]`), will fail and then will get the in_template property. 9 9 10 As of python 3.9 some classes actually are subscriptable and trying to get the item will not fail: Typing shortcuts introduced syntax like `list[int]`. Th is hidesclass properties from the template system.10 As of python 3.9 some classes actually are subscriptable and trying to get the item will not fail: Typing shortcuts introduced syntax like `list[int]`. These hide class properties from the template system. 11 11 12 12 Here's a test (that might go into tests/template_tests/syntax_tests/tests_basic.py) which passes on Python 3.9 and fails on Python 3.10+: