The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Egg::View::Mason - HTML::Mason is used for View of Egg.

SYNOPSIS

This is a setting example.

 VIEW=> [
   [ 'Mason' => {
     comp_root=> [
       [ main   => '/path/to/root' ],
       [ private=> '/path/to/comp' ],
       ],
     data_dir=> '/path/to/temp',
     ... etc.
     } ],
   ],

Example of code.

 $s->{param1}= "fooooo";
 
 $e->view->param( 'param2'=> 'booooo' );
 
 # Scalar reference is received.
 my $body= $e->view->render( 'template.tt' );
 
   or
 
 # It outputs it later.
 $e->template( 'template.tt' );

Example of template.

 <& /comp/html_header, a=> { page_title=> 'test-page' } &>
 <& /comp/banner_head, a=> { type => 1 } &>
 <& /comp/side_menu,   a=> { guest=> 1 } &>
 
 <h1><% $s->{param1} %></h1>
 
 <h2><% $p->{param2} %></h2>
 
 <%init>
 my $array= [
   { name=> 'foo', value=> 'foofoofoo' },
   { name=> 'baa', value=> 'baabaabaa' },
   { name=> 'baa', value=> 'baabaabaa' },
   ];
 </%init>
 <div id="content">
 - Your request passing: <% $e->request->path |h %><hr>
 - Your IP address: <% $e->request->address |h %><hr>
 - Test Array:
 %
 % for my $hash (@$array) {
  [ <% $hash->{name} |h %> = <% $hash->{value} |h %> ],
 % }
 %
 </div>
 <& /comp/html_footer &>

!! It solves it by <% $e->escape_html($var) %> when garbling in <% $var |h %>.

DESCRIPTION

The following global variable can be used.

  • $e = Egg object.

  • $s = $e->stash.

  • $p = $e->view->params.

METHODS

output ([EGG_OBJECT], [TEMPLATE])

The template is output, and it sets it in $e->response->body.

render ([TEMPLATE])

The template is output, and it returns it by the SCALAR reference.

SEE ALSO

HTML::Mason, Egg::View, Egg::Engine, Egg::Release,

AUTHOR

Masatoshi Mizuno, <lushe@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2006 Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.