[Jifty-commit] r3456 - jifty/trunk/lib/Jifty/View/Declare

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Tue Jun 12 15:14:19 EDT 2007


Author: clkao
Date: Tue Jun 12 15:14:08 2007
New Revision: 3456

Modified:
   jifty/trunk/lib/Jifty/View/Declare/BaseClass.pm

Log:
YourApp::View->use_mason_wrapper now lets your write page {} in TD but uses
your mason wrapper.


Modified: jifty/trunk/lib/Jifty/View/Declare/BaseClass.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Declare/BaseClass.pm	(original)
+++ jifty/trunk/lib/Jifty/View/Declare/BaseClass.pm	Tue Jun 12 15:14:08 2007
@@ -13,6 +13,31 @@
 our @EXPORT = ( @Jifty::View::Declare::Helpers::EXPORT);
 
 
+sub use_mason_wrapper {
+    my $class = shift;
+    no strict 'refs';
+    *{ $class . '::wrapper' } = sub ($) {
+        my $code = shift;
+	no warnings 'redefine';
+        # so in td handler, we made jifty::web->out appends to td
+        # buffer, we need it back for here, because $code is actually
+        # called.  someday we need to finish fixing the output system
+        # that is in Jifty::View.
+        my $td_out = \&Jifty::Web::out;
+        local *Jifty::Web::out = sub { shift->mason->out(@_) };
+
+        Jifty->handler->fallback_view_handler->interp->autoflush(1);
+        local *HTML::Mason::Request::content
+            = sub { local *Jifty::Web::out = $td_out; $code; '' };
+        Jifty->web->request->arguments->{title} = 'YADA!';
+        Jifty->handler->fallback_view_handler->show('/_elements/wrapper');
+    }
+}
+
+=cut
+
+
+
 1;
 __DATA__
 
@@ -27,6 +52,11 @@
 
 =head1 METHODS
 
+=head2 use_mason_wrapper
+
+Call this function in your viewclass to use your mason wrapper for TD templates.
+
+
 =head2 show templatename arguments
 
 Render a C<Template::Declare> template.


More information about the Jifty-commit mailing list