On Mon, Apr 3, 2017 at 11:38 AM, iaw4 <[email protected]> wrote:
> They should not need to know anything about M, except for the template
> syntax. (I may need to give them instructions about how to add a new page,
> too.) They should not have to know about controllers, models, views,
> hierarchies, directory organization, differences in M and M-Lite, testing,
> and perhaps even perl itself. This is a "near zero" learning curve.
> Otherwise, my project will have failed.
>
I would argue (perhaps incorrectly) that this is *exactly* the intent of a
View. It allows your users to be ignorant (not derogatory) of Controllers
and Models and by-and-large Mojolicious. Like you said, point them to
template syntax and they can take it away! No need (or even desire) to
have templates combined with your Controller.
That said, feel free to have your templates with your Controller. I just
thought I'd point that out. :D
> So far, I had thought that M::Lite was the way to go. It's minimalist,
> which is great. I tried 'use example', to pull in example.pm, but I
> could not make this work. if it did work, I would be done! This was my
> ideal solution. Even the original main M-Lite script would be easy to
> understand in the future, as it would just contain 500 use statements. if
> this could be made to work, I would be eternally grateful for a working
> example.
>
This I just don't understand. :( I don't see what you're trying to
accomplish with "use example". If you're referring to your example code
below, let me address that...
> $ mojo generate app MyApp
> $ cd my_app
> $ rm templates/example/welcome.html.ep
> ## here I make some changes, so...
> $ cat lib/MyApp/Controller/Example.pm
> package MyApp::Controller::Example;
> use Mojo::Base 'Mojolicious::Controller';
> use Mojo::Loader 'data_section';
>
> sub example {
> my $self = shift;
> $self->render(*inline => data_section('MyApp::Controller::Example',
> 'example.html.ep'), *msg => 'Modded Example to the Mojolicious real-time
> web framework!');
> }
> 1;
>
> __DATA__
> @@ example.html.ep
> Example.pm <%= $msg %>
>
>
> Now I am stuck at a beginner's puzzle. I want to hook this into the URL
> '/example'. I look at MyApp.pm, where I see
>
> $r->get('/')->to('example#example');
>
>
> The syntax was a bit baffling. I needed to understand what # means.
> After searching the tutorial and growing, I did find it eventually in
> routing as '*Controller classes are perfect for organizing code in
> larger projects. There are more dispatch strategies, but because
> controllers are the most commonly used ones they also got a special
> shortcut in the form of controller#action**.*' ok, I presume this means
> that the first example is the name of the file 'Example.pm', and the second
> example is the name of the function. ok, so I should be set.
>
You got it! No need for me to elaborate further. :)
> unfortunately, I seem to be only half set.
>
> $ morbo script/my_app
>
> gives me a befuddling error message. I see from the stash that sub
> example in Example.pm was running. (Yeah!!) Alas, it also tells me that
> "Page not found... yet!" This may require only a very trivial fix, but I
> have no idea what.
>
Right! Add the inline section that I added inside your sample code. I
don't know that using "inline" is the *best* way to do this, but right now
you just want to see *something* work! :D
--
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.