Skip to content

Commit 25ebf9c

Browse files
committed
Add some debugging for testing component arguments to the todo example.
1 parent bf654c8 commit 25ebf9c

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

example/unicorn/components/todo.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,21 @@ class TodoView(UnicornView):
1313
task = ""
1414
tasks = []
1515

16+
def __init__(self, *args, **kwargs):
17+
super().__init__(**kwargs)
18+
self.hello = kwargs.get("hello", "not available")
19+
print("__init__() self.request", self.request)
20+
print("__init__() self.hello", self.hello)
21+
22+
def hydrate(self):
23+
print("hydrate() self.hello", self.hello)
24+
25+
def mount(self):
26+
print("mount() self.hello", self.hello)
27+
1628
def add(self):
29+
print("add() self.hello", self.hello)
30+
1731
if self.is_valid():
1832
self.tasks.append(self.task)
1933
self.task = ""

example/unicorn/templates/unicorn/todo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<div class="field has-addons">
77
<p class="control">
88
<form unicorn:submit.prevent="add">
9-
<input class="input" type="text" unicorn:model.lazy="task" unicorn:keydown.escape="task=''" placeholder="New task" id="task"></input>
9+
<input class="input" type="text" unicorn:model="task" unicorn:keydown.escape="task=''" placeholder="New task" id="task"></input>
1010
</form>
1111
</p>
1212
<p class="control">

example/www/templates/www/html-inputs.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ <h2>Other inputs</h2>
77

88
{% unicorn 'html-inputs' %}
99

10-
{% unicorn 'todo' %}
10+
{% unicorn 'todo' hello='world' %}
11+
12+
{% unicorn 'todo' hello=example %}
1113

1214
{% endblock content %}

example/www/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ def index(request):
99

1010
def template(request, name):
1111
try:
12-
return render(request, f"www/{name}.html")
12+
return render(request, f"www/{name}.html", context={"example": "test"})
1313
except TemplateDoesNotExist:
1414
raise Http404

0 commit comments

Comments
 (0)