Docendo discimus

$self->explain

  • Calendar

    July 2017
    M T W T F S S
    « Sep    
     12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31  
  • Archives

  • Recent Posts

  • Bling

Posts Tagged ‘top searches’

Top Searches (July)

Posted by brunorc on July 27, 2009

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.

Posted in Catalyst for intimidated | Tagged: , , , , , , , , | 2 Comments »

Catalyst is easy – do the wrong thing

Posted by brunorc on July 13, 2009

Someone landed here while searching for the phrase get catalyst object in model. Before I wrote in one of previous entries:

methods of the model don’t have access to the Catalyst context object, because, in fact, they shouldn’t have it

I first searched for the possibilities of doing it. And there are such possibilities, which shouldn’t be surprising, as Catalyst allows one to write all the crap one wants to write – it will just help to write it faster.

So if you really want to use the context object inside your Model (or View), take a look at the ACCEPT_CONTEXT component – and please read the WARNING WARNING WARNING section. In many cases passing some arguments should be sufficient. While being able to do absolutely any crap you can fancy is a nice possibility by itself, it also pays to read the manual of your chainsaw before the first launch. At least you can take advantage of turning the pages with any of your hands.

Having said this, I’d like to point that ACCEPT_CONTEXT even made its way to Catalyst Advent Calendar. It means that sharp tools can be also useful.

P.S. I planned to write about the installation of Catalyst on Windows XP, however it has been postponed (but not forgotten).

Posted in Catalyst for intimidated | Tagged: , , , , , , , , | Leave a Comment »

Top Searches

Posted by brunorc on June 16, 2009

I stumbled upon a small box showing most popular phrases people use to feed Google (probably) in order to find a way to my blog. Some of them are quite interesting and I decided to address them here.

catalyst html a href doesnt work
It works perfectly! But probably the problem was with uri_for… we get there someday.
cannot see catalyst
Blessed are those who believe without seeing! But I will keep showing, just in case.
perl catalyst rulez
You bet it!
perl catalyst “page not found”
In the next episode, I promise!

Posted in Uncategorized | Tagged: | Leave a Comment »