[Catalyst-commits] r6773 - trunk/Catalyst-View-Mason

rafl at dev.catalyst.perl.org rafl at dev.catalyst.perl.org
Tue Aug 28 16:59:58 GMT 2007


Author: rafl
Date: 2007-08-28 16:59:58 +0100 (Tue, 28 Aug 2007)
New Revision: 6773

Modified:
   trunk/Catalyst-View-Mason/README
Log:
Update README.


Modified: trunk/Catalyst-View-Mason/README
===================================================================
--- trunk/Catalyst-View-Mason/README	2007-08-28 15:59:56 UTC (rev 6772)
+++ trunk/Catalyst-View-Mason/README	2007-08-28 15:59:58 UTC (rev 6773)
@@ -10,47 +10,86 @@
 
         use base 'Catalyst::View::Mason';
 
-        __PACKAGE__->config->{DEBUG} = 'all';
-        __PACKAGE__->config->{comp_root} = '/path/to/comp_root';
-        __PACKAGE__->config->{data_dir} = '/path/to/data_dir';
+        __PACKAGE__->config(use_match => 0);
 
         1;
-    
+
         $c->forward('MyApp::View::Mason');
 
 DESCRIPTION
     Want to use a Mason component in your views? No problem!
     Catalyst::View::Mason comes to the rescue.
 
-CAVEATS
-    You have to define "comp_root" and "data_dir". If "comp_root" is not
-    directly defined within "config", the value comes from "config-"{root}>.
-    If you don't define it at all, Mason is going to complain :) The default
-    "data_dir" is "/tmp".
+EXAMPLE
+    From the Catalyst controller:
 
+        $c->stash->{name} = 'Homer'; # Pass a scalar
+        $c->stash->{extra_info} = {
+                   last_name => 'Simpson',
+                   children => [qw(Bart Lisa Maggie)]
+        }; # A ref works too
+
+    From the Mason template:
+
+        <%args>
+        $name
+        $extra_info
+        </%args>
+        <p>Your name is <strong><% $name %> <% $extra_info->{last_name} %></strong>
+        <p>Your children are:
+        <ul>
+        % foreach my $child (@{$extra_info->{children}}) {
+        <li>$child
+        % }
+        </ul>
+
 METHODS
-   process
+  new
+  process
     Renders the component specified in $c->stash->{template} or
-    $c->request->match to $c->response->output.
+    $c->request->match or $c->action (depending on the use_match setting) to
+    $c->response->body.
 
     Note that the component name must be absolute, or is converted to
-    absolute (ie, a / is added to the beginning if it doesn't start with
-    one)
+    absolute (i.e., a / is added to the beginning if it doesn't start with
+    one).
 
-    Mason global variables $base, $c and c<$name> are automatically set to
-    the base, context and name of the app, respectively.
+    Mason global variables $base, $c, and c<$name> are automatically set to
+    the base, context, and name of the app, respectively.
 
+  render($c, $component_path, \%args)
+    Renders the given template and returns output, or a
+    HTML::Mason::Exception object upon error.
+
+    The template variables are set to %$args if $args is a hashref, or
+    $c->stash otherwise.
+
    config
-    This allows your view subclass to pass additional settings to the Mason
-    HTML::Mason::Interp->new constructor.
+    This allows you to to pass additional settings to the
+    HTML::Mason::Interp constructor or to set the options as below:
 
+    "use_match"
+        Use "$c->request->match" instead of "$c->action" to determine which
+        template to use if "$c->stash->{template}" isn't set. This option is
+        deprecated and exists for backward compatibility only.
+
+        Currently defaults to 1.
+
+    The default HTML::Mason::Interp config options are as follows:
+
+    "comp_root"
+        "$c->config->root"
+
+    "data_dir"
+        "File::Spec->tmpdir"
+
 SEE ALSO
     Catalyst, HTML::Mason, "Using Mason from a Standalone Script" in
     HTML::Mason::Admin
 
 AUTHOR
     Andres Kievsky "ank at cpan.org" Sebastian Riedel "sri at cpan.org" Marcus
-    Ramberg
+    Ramberg Florian Ragwitz <rafl at debian.org>
 
 COPYRIGHT
     This program is free software, you can redistribute it and/or modify it




More information about the Catalyst-commits mailing list