Hello all,
for a while I have been trying to get at the name of the template that
is just being rendered, to use it in the layout. I have dug through
documentation and source code, and while I found the place where the
debug message qq{Rendering template "$name"} is emitted, I haven't yet
found a good way to get at that name.
Now I did this (as a helper function):
sub current_template_name {
my ($c) = @_;
my $loghist = $c->app()->log()->{history};
my $try = -1;
my $msg;
do {
$msg = $loghist->[$try--]->[2];;
} while ($msg =~ m{\"layouts/} && -$try < @{$loghist});
$msg =~ s/^[^"]*"(.*)".*/$1/;
return $msg;
}
I am pretty certain everybody agrees that this is as ugly as it can get.
Now, what is the preferred way to get at the template name?
(BTW, I *really* like Mojolicious. While I am an experienced programmer,
this is my first real endeavor into web applications, so I was a bit
overwhelmed at first. An excellent training by Renée Bäcker put me on
the right track, and now I am happily hacking away.)
Regards, Juergen.
--
<
Juergen....@fu-berlin.de> Tel
+49.30.838-50740 Fax -450740
Zentraleinrichtung fuer Datenverarbeitung, Central Systems (Unix)
Freie Universitaet Berlin, Fabeckstrasse 32, 14195 Berlin, DE