but i am
"Say I am proud and sane and wise - an Athenian among Greeks. Well, I might fail where a lesser man would succeed. He could imitate, he could adorn, he could be enthusiastic, he could be hopefully constructive. But this hypothetical me would be too proud to imitate, too sane to be enthusiastic, too sophisticated to be utopian, too grecian to adorn." – Anthony Patch in F. Scott Fitzgerald's, "The Beautiful And The Damned"
understanding someone sharing something
"I believe if there's any kind of God it wouldn't be in any of us, not you or me but just this little space in between. If there's any kind of magic in this world it must be in the attempt of understanding someone sharing something. I know, it's almost impossible to succeed but who cares really? The answer must be in the attempt." – Celine, from Before Sunrise
Selectively disabling TT wrapper in Catalyst
The following is a method for Catalyst sites using Template Toolkit with a site-wide WRAPPER directive to selectively return partial HTML for the purpose of serving Asynchronous HTML and HTTP (ie, “AHAH’).
Catalyst is a powerful and versatile web development framework that aims to be Perl’s counterpart to Ruby on Rails, fusing a Model-View-Controller (MVC) environment with the depth, breadth, and power of CPAN. If you build web sites with Perl, you should check it out.
The problem: you want to use TT’s WRAPPER directive to supply a site-wide wrapper template, but you also want to be able to selectively turn the wrapper off so that you can serve some pages as partial HTML. At first glance, Catalyst’s config() method might suggest that one could reconfigure your view in your action’s end(), but that proves fruitless and it clucks in the following manner:
[warn] Setting config after setup has been run is not a good idea.
My solution: create an end()
in your controller that emits “partial” HTML fragments by creating a new Template Toolkit object with a locally-defined configuration. (Note that since we override the root controller’s end()
, we must call forward/detach to it if we do not specify the “partial” parameter.)
sub end : Private {
my ($self, $c, $file) = @_;
my $params = $c->request->parameters;
if (exists $params->{'partial'}) {
my $html;
my $tt = Template->new({
%{ $c->config->{'View::TT'} },
INCLUDE_PATH => $c->path_to('root'),
WRAPPER => undef,
});
$tt->process($file, $c->stash, \$html) or $c->log->warn($tt->error);
$c->response->content_type('text/html');
$c->response->body($html);
}
else {
$c->detach(qw/CE::Controller::Root end/);
}
}
A more robust solution better-suited for larger projects might be a new view with an alternate configuration (eg, a custom View::TTpartial,) but I wanted to show the logic directly in my controller, allowing full control of the configuration and direct access to the $html.
Coming soon: the “data island” solution I ultimately opted for to obviate AHAH for serving map marker data to a Google map.
art is not enough
"If people bring so much courage to this world the world has to kill them to break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry." – Ernest Hemingway, in "A Farewell to Arms"