code and template in unix files accdg to route?

20 views
Skip to first unread message

iaw4

unread,
Mar 13, 2017, 10:26:39 PM3/13/17
to Mojolicious

dear M experts----beginner's question.

I like the structure and simplicity of M Lite even more than I like that of M (at least for now).  Of course, Lite wouldn't work with more than a few routes.  what I would like is to have my code be together in one file with its template, and store it in the unix file structure that gives it its name.  (this is not to argue that this is a better way to do this; just a personal preference.  it makes it easy to look at the URL and find all associated source code.)

so, for example, I may want to store in

/student/workonme:
use Mojolicious::Lite;
use mystuff; 
# Route is determined by the file name now, so

# get or post '/student/workonme' => 

sub {
  my $c = shift;
  $c->stash(one => 23);
  $c->render(template => 'magic', two => 24);
};

app->start;
__DATA__
@@ magic.html.ep
The magic numbers are <%= $one %> and <%= $two %>.
I don't know how to distinguish between gets and puts in this sort of organization (yet).  now, when a URL request arrives, M would just look it up in the unix file structure.

if this functionality exists, could someone please point me to it?  pointers appreciated.

regards,

/iaw

iaw4

unread,
Mar 18, 2017, 8:42:47 PM3/18/17
to Mojolicious

the answer is Yuki Kimoto > Mojolicious-Plugin-AutoRoute > Mojolicious::Plugin::AutoRoute .
Reply all
Reply to author
Forward
0 new messages