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

@ -1,3 +1,5 @@
from typing import NamedTuple
from django_components import Component, register
@ -13,9 +15,12 @@ class CalendarNested(Component):
js_file = "calendar.js"
# This component takes one parameter, a date string to show in the template
def get_context_data(self, date):
class Kwargs(NamedTuple):
date: str
def get_template_data(self, args, kwargs: Kwargs, slots, context):
return {
"date": date,
"date": kwargs.date,
}
class View: