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.

-- 
<[email protected]> Tel +49.30.838-50740 Fax -450740
Zentraleinrichtung fuer Datenverarbeitung, Central Systems (Unix)
Freie Universitaet Berlin, Fabeckstrasse 32, 14195 Berlin, DE

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to