Update: Diego pointed out something very important, so this post had to be significantly updated.
Someone came here searching for catalyst mason variables stash. It brought me to the question: how do I access stash from the Mason view? The answer is: the same way as in TT(Site) view. Mason page is just passed the stash content, so it’s enough to declare variables we want to use in our view.
A small example: let’s put something like this in our controller:
sub uruk_hai :Local :Args(0) {
my ( $self, $c ) = @_;
$c->stash->{message} = 'We will feast on manflesh!';
$c->stash->{template} = 'uruk_hai.html';
}
Now if we want to use TT(Site), our template will look like this:
<h2>[% message %]</h2>
In Mason it looks like this:
<%args> # don't die if there's no message $message => undef </%args> <h2><% $message %></h2>
Moreover, the Catalyst::View::Mason module declares some useful globals, like $c, $base and $name, so we can choose between Mason and TT without sacrificing anything.
