Hi,
I'm writing a fairly large Mojolicious app and I'd like some advice on
where to place the logic of the display or view. My model queries a
database and returns a data stucture with the results. Then my
templates pull the data from the structure and format it. I think
this is all fairly normal.
The problem is that some of the display logic is fairly complicated:
one of my templates has a 30 line <% %> block before anything can be
displayed. It strikes me that these 30 lines (and others) are better
off in a subroutine or method. But where? MyApp::View? How would I
call it from a template? None of the documentation I can find
addresses this. I appreciate any pointers or examples.
Thanks,
Jim
P.S. The templates look something like:
<%
my @foobar;
for my $foo ( @row->{foo}) {
my $foobar;
$foobar .= "$foo->{baz}: " if $foo->{baz};
$foobar .= $foo->{bar}->join( ', ');
push @foobar, $foobar;
}
my $foobars = join '; ', @foobar;
%>
% if ($foobars) {
<p>Foobar is <%= $foobars %>.<p>
%>
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/mojolicious/20200729111238.1f86ccdc%40doliolum.thaliacea.lan.