@@ -51,9 +51,7 @@ has Todo @.todos;
5151
5252method RENDER ($ _ ) {
5353 . ol: {
54- for @ ! todos -> Todo $ todo {
55- . add-child: $ todo
56- }
54+ . add-children: @ ! todos ;
5755 }
5856 . form:
5957 : endpoint(self . new-todo),
@@ -66,40 +64,55 @@ method RENDER($_) {
6664method new-todo (Str : $ description ! )
6765is endpoint{
6866 : path</bla >,
69- : return( -> | { boilerplate : title( " My TODO list " ), { . add-child : TodoList . new } })
67+ : redirect< / >,
7068} {
7169 @ ! todos . push : Todo. new : : $ description ;
7270}
7371```
7472
7573``` 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
7789use v6.d ;
7890
7991use Humming-Bird::Core;
8092use HTML::Component::Boilerplate;
8193use lib " examples" ;
8294use TodoList;
8395use Todo;
96+ use App;
8497use HTML::Component::Endpoint;
8598
86- my $ index = boilerplate : title( " My TODO list " ), { . add-child : TodoList . new }
99+ my $ index = App . new . RENDER;
87100my $ html = $ index . HTML;
88101
89102get (' /' , -> $ request , $ response {
90- $ response . html($ html );
103+ $ response . html(App . new . RENDER . HTML );
91104});
92105
93106for HTML::Component::Endpoint. endpoints {
94107 if . verb. uc eq " GET" {
95108 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;
97111 }
98112 }
99113}
100114
101115listen(12345 );
102-
103116```
104117
105118# DESCRIPTION
0 commit comments