@@ -51,9 +51,7 @@ has Todo @.todos;
51
51
52
52
method RENDER ($ _ ) {
53
53
. ol: {
54
- for @ ! todos -> Todo $ todo {
55
- . add-child: $ todo
56
- }
54
+ . add-children: @ ! todos ;
57
55
}
58
56
. form:
59
57
: endpoint(self . new-todo),
@@ -66,40 +64,55 @@ method RENDER($_) {
66
64
method new-todo (Str : $ description ! )
67
65
is endpoint{
68
66
: path</bla >,
69
- : return( -> | { boilerplate : title( " My TODO list " ), { . add-child : TodoList . new } })
67
+ : redirect< / >,
70
68
} {
71
69
@ ! todos . push : Todo. new : : $ description ;
72
70
}
73
71
```
74
72
75
73
``` raku
76
- # humming-bird-todo.raku
74
+ # examples/App.rakumod
75
+ use TodoList;
76
+ use HTML::Component;
77
+ use HTML::Component::Boilerplate;
78
+ unit class App does HTML::Component;
79
+
80
+ method RENDER ($? ) {
81
+ boilerplate
82
+ : title(" My TODO list" ),
83
+ *. add-child: TodoList. new
84
+ }
85
+ ```
86
+
87
+ ``` raku
88
+ # examples/humming-bird-todo.raku
77
89
use v6.d ;
78
90
79
91
use Humming-Bird::Core;
80
92
use HTML::Component::Boilerplate;
81
93
use lib " examples" ;
82
94
use TodoList;
83
95
use Todo;
96
+ use App;
84
97
use HTML::Component::Endpoint;
85
98
86
- my $ index = boilerplate : title( " My TODO list " ), { . add-child : TodoList . new }
99
+ my $ index = App . new . RENDER;
87
100
my $ html = $ index . HTML;
88
101
89
102
get (' /' , -> $ request , $ response {
90
- $ response . html($ html );
103
+ $ response . html(App . new . RENDER . HTML );
91
104
});
92
105
93
106
for HTML::Component::Endpoint. endpoints {
94
107
if . verb. uc eq " GET" {
95
108
get . path , -> $ request , $ response {
96
- $ response . html: . run-defined(Any , | $ request . query<> )
109
+ $ response . html: . run-defined(Any , | $ request . query<> ). Str ;
110
+ $ response . redirect: $ _ with . redirect;
97
111
}
98
112
}
99
113
}
100
114
101
115
listen(12345 );
102
-
103
116
```
104
117
105
118
# DESCRIPTION
0 commit comments