thank you, stefan. I wonder how M executes embedded perl code. does it simply ignore the 'use model', altogether?
my webapp needs simplicity and understandability/maintainability by non-MVC people. it is not a full-time venture, but will be written once, then not looked at for years, then tinker with by someone else, etc. my planned controller-view design is not universal, but it suits my particular project needs. see, I have many, many URLs, each with short code and short template. Thus, combining each URL into its small code bundled with its template is very appealing. the M-Lite is too lite for me (which does keep code and templates together [good], albeit in ONE GIANT file [bad]), the M structure is too heavy---and although I have read "growing" a few times, it isn't fully clear to me. there is a lot of magic there. (I also don't have a web designer, so keeping the view separate is less important to me.) I need the Mojolicious::Medium---each URL containing its controller and view in one file each, and each URL just pulls in from model.pm whatever model aspects that it needs. I had seen the helper functions in the (very nice) tutorial, too, but it does not seem nice/practical to transform every single model by hand into a helper function. or is there a way to instruct M to helper-ize a hundred functions? thanks again. /iaw On Sunday, April 2, 2017 at 7:43:52 PM UTC-7, Stefan Adams wrote: > > > On Sun, Apr 2, 2017 at 9:29 PM, iaw4 <[email protected] <javascript:>> > wrote: > >> I would like to keep my view together with my controller. >> > > This sounds in opposition of good / supported design. Reference > <http://mojolicious.org/perldoc/Mojolicious/Guides/Growing#Model-View-Controller> > > >> My model sits in the perl model.pm file. So, I want 'use model' be >> picked up inside my index.html.ep template. 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. >> > > You want the view to have access to the Model, just as the Controller > would? Reference > <http://mojolicious.org/perldoc/Mojolicious/Guides/Growing#Model> > > Using a helper in your Controller, you'll store your Model object, and > your View will have access to your Controller's helper which stores the > Model. This will give you access to the Model's subs. > > Pay special attention to the last block of code in the second Reference I > gave, "Model". > > Feel free to ask any questions about this documentation from the Mojolicious > Growing Guide <http://mojolicious.org/perldoc/Mojolicious/Guides/Growing>. > -- 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.
