refactor: Update docs and tests to use get_template_data() (#1161)

* refactor: update docs and tests to use get_template_data()

* refactor: fix linting

* docs: add note about difference between the two methods
This commit is contained in:
Juro Oravec 2025-05-03 12:04:10 +02:00 committed by GitHub
parent c69980493d
commit 28b61c1609
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
69 changed files with 795 additions and 725 deletions

View file

@ -25,10 +25,10 @@ class SimpleComponent(Component):
Variable: <strong>{{ variable }}</strong>
"""
def get_context_data(self, variable, variable2="default"):
def get_template_data(self, args, kwargs, slots, context):
return {
"variable": variable,
"variable2": variable2,
"variable": kwargs["variable"],
"variable2": kwargs.get("variable2", "default"),
}
class Media:
@ -55,7 +55,7 @@ class SimpleComponentNested(Component):
console.log("Hello");
"""
def get_context_data(self, variable):
def get_template_data(self, args, kwargs, slots, context):
return {}
class Media:
@ -78,7 +78,7 @@ class OtherComponent(Component):
console.log("xyz");
"""
def get_context_data(self, variable):
def get_template_data(self, args, kwargs, slots, context):
return {}
class Media:
@ -91,7 +91,7 @@ class SimpleComponentWithSharedDependency(Component):
Variable: <strong>{{ variable }}</strong>
"""
def get_context_data(self, variable, variable2="default"):
def get_template_data(self, args, kwargs, slots, context):
return {}
class Media: