Changes between Version 2 and Version 3 of Ticket #35735


Ignore:
Timestamp:
Sep 5, 2024, 12:59:31 PM (3 months ago)
Author:
Fabian Braun
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #35735

    • Property Has patch set
  • Ticket #35735 – Description

    v2 v3  
    66you could access the class property in the template through (if it was returned by a callable) `{{ get_my_class.in_template }}`.
    77
    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.
     8The 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.
    99
    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]`. This hides class properties from the template system.
     10As 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.
    1111
    1212Here'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+:
Back to Top