Dear M experts---I am making good progress, but please excuse my continuing
questions. I would like to keep my view together with my controller. My
model sits in the perl model.pm file. So, I want 'use model' be picked up
inside my index.html.ep template. Here is the example:
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => sub { my $c = shift; $c->render(template => 'index'); };
app->start;
__DATA__
@@ index.html.ep
% layout 'default';
% title 'Quick Test';
<%
use model; ## model.pm contains 'sub hello { return "hello from sub"; }'
my $hello= hello(); ## not picked up---why??
$self->stash( hello => $hello );
%>
<h1>Quick Test</h1>
<p> hello is <%= $hello %>
Is there a way to wholesale import `model.pm`, just as I could use it in
controller perl code, and then I could use the model's subs in the template
perl section? help, as always, appreciated.
regards,
/iaw
--
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 https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.