Permalink
Browse files

two new actions, now showing how to get a capture to be used as an ar…

…gument to the closure...
  • Loading branch information...
1 parent a734592 commit b8f6a30198e4b73d91a17bfabdf9b40d64818760 @ruoso committed May 14, 2009
Showing with 35 additions and 0 deletions.
  1. +35 −0 examples/yarn/lib/Yarn.pm
View
@@ -86,6 +86,41 @@ class Yarn is Faz::Application {
})
);
self.register-action($create);
+
+ my $post = Faz::Action::Chained.new\
+ ( :private-name('(root)/*'),
+ :regex(/ \/ (\d+) /),
+ :parent($root),
+ :finish-closure({ 1; }),
+ :execute-closure({ 1; }),
+ :begin-closure( -> $post_id {
+ %*stash<post> = %*stash<posts>[$post_id];
+ })
+ );
+ self.register-action($post);
+
+ my $view_post = Faz::Action::Public.new\
+ ( :private-name('(root)/*/'),
+ :regex(/ \/? $ /),
+ :parent($post),
+ :finish-closure({ 1; }),
+ :begin-closure({ 1; }),
+ :execute-closure({
+ $*response.write(show {
+ html {
+ head { title { 'Yarn' } }
+ body {
+ div :class<post>, {
+ h1 { %*stash<post><title> };
+ div { %*stash<post><content> };
+ }
+ }
+ }
+ });
+ })
+ );
+ self.register-action($view_post);
+
$.dispatcher.compile;
}

0 comments on commit b8f6a30

Please sign in to comment.