The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2018-01-13

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:00 marty_ joined #mojo
00:29 Seth joined #mojo
00:59 aborazmeh joined #mojo
01:06 Helolo joined #mojo
01:06 Helolo Helo guys
01:25 Grinnz weird how people keep doing that
01:30 pink_mist short but sweet?
01:36 marty joined #mojo
05:04 dboehmer_ joined #mojo
05:18 gordonfish joined #mojo
05:27 blaphmat joined #mojo
05:58 ferreira joined #mojo
07:31 Vandal joined #mojo
07:43 sh14 joined #mojo
08:09 ferreira joined #mojo
08:18 raha joined #mojo
08:41 trone joined #mojo
10:43 dod joined #mojo
10:49 dod joined #mojo
12:38 raha joined #mojo
12:38 raha Hi everybody
12:38 purl Hi, Dr. Nick!
12:40 raha I have a simple question, why should we use templateing? with the notation created in mojolicious, the template designer should already know how to code in perl, Then what's the point in using new syntax?
12:42 raha I have rewrite the example in this link http://mojolicious.org/perldoc/Mojolicious/Guides/Growing#WELL-STRUCTURED-APPLICATION
12:42 pink_mist I'm not sure I understand your question exactly, are you asking why one should use templates at all?
12:43 pink_mist or are you asking why one should specifically use the EP templates mojo provides?
12:43 raha why should we use EP ?
12:43 raha why not using Perl itself
12:44 raha could I upload file here? I will show what I mean
12:44 pink_mist now I'm confused again
12:44 pink_mist 13:43 <raha> why should we use EP ? <-- that line implies you meant my second line, 13:44 <raha> why not using Perl itself <-- that line implies you meant my first line
12:45 pink_mist can you please specify specifically what you're asking about
12:45 raha ok what is template?
12:45 purl somebody said template was the reason or Template Toolkit (http://search.cpan.org/~abw/Template-Toolkit-2.15/) or at http://www.template-toolkit.org/ or right I see the h1
12:46 raha some html code which will help us to preserve the look and feel in app
12:46 raha is that right?
12:48 raha @@ index.html.ep % layout 'default'; %= form_for index => begin   % if (param 'user') {     <b>Wrong name or password, please try again.</b><br>   % }   Name:<br>   %= text_field 'user'   <br>Password:<br>   %= password_field 'pass'   <br>   %= submit_button 'Login' % end  @@ protected.html.ep % layout 'default'; % if (my $msg = flash 'message') {   <b><%= $m
12:48 pink_mist templates allow you to have a baseline for what the page should look like, and only giving it some data that alters the specifics
12:49 raha ok that's good, Perl itself is great string processing tool why not using it?
12:49 pink_mist because that was tried already in the CGI.pm days, and it was absolutely horrible
12:50 raha I wish if I can upload my code here to show my Idea :|
12:50 pink_mist having print('<html><head>...</head><body>...</body></html>); in the code is absolutely atrocious
12:50 pink_mist use a gist to show code
12:51 pink_mist (and I missed the ending ')
12:51 raha gist
12:52 pink_mist anyway, templates are the view component of the MVC pattern, which mojo recommends using
12:52 pink_mist it doesn't force you to use MVC though
12:52 pink_mist you can mess things up any way you like
12:53 raha yes sure I will use MVC,
12:53 pink_mist the MVC pattern recommends separating models, views, and controllers, part of this means having as little actual code in the view component as possible
12:53 raha just let me second to upload the file in gist and I will be back here
12:54 pink_mist note that Mojolicious doesn't force you to use EP templates. you can use any other perl templating system of your liking; Template Toolkit is very popular for instance
12:55 pink_mist it's just that EP templates are included
12:59 raha ok look at this link https://gist.github.com/anonymous/91d14f49f19d411c1bb0e2bcfba4dc7f
13:00 raha look at file structure first I have Controller , Model , and View there
13:01 raha in View I have login.pm in Controller and login.pm in View
13:01 pink_mist yeah I see what you're doing, and it's absolutely horrible
13:01 raha and I call View the same way I call my Model
13:02 pink_mist having to look through the perl source files to find the HTML code is a horrible idea
13:02 pink_mist at least separate it to a __DATA__ section
13:03 pink_mist and that's definitely not MVC
13:03 pink_mist you're actually writing code to support pyour view component
13:03 pink_mist that's the opposite of what you should do
13:03 raha did I have seperated View from Model and Controller?
13:03 pink_mist you should have as little code as possible in the view
13:06 raha But having those EP code in html section is as horrible too, isnot it?
13:06 pink_mist you should have as little code as possible in the view <-- it allows you to have _very little code_ in the template
13:07 pink_mist you should have as little code as possible to support your functionality
13:08 pink_mist but the biggest issue is that you're actually having strings inside your perl source to construct the HTML pages
13:08 pink_mist that's just atrocious
13:09 pink_mist plus you're missing all the usefulness of the helpers
13:09 raha look at __DATA__ section of this link http://mojolicious.org/perldoc/Mojolicious/Guides/Growing#Final-prototype
13:10 raha is this really more readable than my code? more maintainable?
13:10 pink_mist absolutely
13:10 purl Oh my, yes.
13:10 pink_mist however, you should separate out the layouts and templates into their own files
13:10 pink_mist that's the POINT of the growing guide
13:11 pink_mist http://mojolicious.org/perldoc/Mojolicious/Guides/Growing#Inflating-templates shows you how
13:11 raha Ja sure, I just write them in one file to prove a concept :))
13:12 pink_mist you're still constructing HTML pages by concatenating strings inside your perl source files
13:12 pink_mist it's horrible
13:13 raha ok I have no previous web developing backgraound
13:14 raha but your words telling me that I will get better understanding of the cause by little more experiences
13:14 pink_mist yeah, probably
13:14 pink_mist what you're describing used to be how it was done
13:15 pink_mist back in the 90s and by some people in the early 2000s
13:15 pink_mist but it's not being done anymore because templates allow much easier maintenance
13:15 raha it more like writing OOP vs structured programming
13:16 raha mean while if you introduce me some resource about this I will appriciate
13:17 pink_mist sorry, I'm not the right person to be able to give you such things; I'm only talking from my own experience ... other people in here will probably be able to give you enlightening material to read
13:17 pink_mist if you wait for others to show up :P
13:19 raha thx anyway buddy ;)
13:23 sh14 joined #mojo
13:39 jberger raha think of it this way
13:40 jberger Since most of what you are going to generate will be the same html independent of the specific data ...
13:40 raha ok
13:41 jberger templates invert the notion that in a Perl script "everything is code unless you make it a string"
13:41 jberger To now "everything is a string unless I make it code"
13:42 jberger Indeed what you are showing is what the template looks like once it is complied
13:42 jberger But there's no reason for you to have to do that every time
13:43 jberger And as you get deeper in, the composability of template sections would end up making your way more limiting I suspect
13:45 jberger But if nothing else just know that as pink_mist mentioned, your theory isn't an incorrect one to try, just that it has been tried
13:45 jberger And was the primary way that things were sombre 20 years ago, and it was so bad in practice that they came up with something else
13:46 raha you mean the way I have presented it ( the composability of template sections would end up making your way more limiting)
13:46 jberger Yeah
13:47 raha I feel i need more practice on it to get the idea
13:47 jberger Sure, certainly doesn't hurt to try it the hard way to learn
13:47 raha but my design still follow MVC isnot it?
13:48 jberger I suppose by a technical sense yes
13:49 jberger But in practice that's really never done anymore
13:49 raha consider my background is desktop development, and I am using similar design there
13:50 raha but sure in web development u suggest using templating in View
13:53 raha may I ask another question know ? which templating engine do u suggest? EP or TT or other if there is any? in term of popularity, support and documentation?
13:56 ghenry joined #mojo
14:29 raha joined #mojo
14:31 raha left #mojo
14:34 mishanti1 raha: For mojo i only use ep. For some older projects I have used TT, but much prefer ep.
14:40 sri raha: if there's one thing we've learned in the last decade it's that strict MVC like we recommend it in the guides now works best for making apps maintainable
14:41 sri we've tried it all, and this is what works best
14:44 ChmEarl joined #mojo
14:51 ferreira joined #mojo
15:14 raha joined #mojo
15:23 ferreira joined #mojo
15:30 kjhsdckjh joined #mojo
15:32 raha joined #mojo
17:11 maschine joined #mojo
17:22 gryphon joined #mojo
17:26 ghenry joined #mojo
17:46 marty joined #mojo
18:09 mishantil joined #mojo
18:14 mishanti1 joined #mojo
19:11 marty joined #mojo
21:06 ferreira joined #mojo
22:49 ghenry joined #mojo
23:46 sjn joined #mojo

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary