scriptlets in view

7 views
Skip to first unread message

Claudio Tasso

unread,
Apr 15, 2012, 2:15:08 PM4/15/12
to ronin...@googlegroups.com
Hi guys,
I'm taking a look at Ronin web framework.
Reading the documentation, I see that it's possible to include scriptlets in HTML templates and it seems that it's a feature by design.
I'm a bit puzzled, don't you think that it is a bad practice to include scriptlets in the view?
Following this approach, logic which should reside in the controller tends to be included in the view and, consequently, the view becomes a mess.
This not a flame, I'm just an old web developer who would like to understand why a brand new cool framework has designed in a such way, I'm sure that you have a lot of good reasons... :-)

Claudio 

Carson Gross

unread,
Apr 15, 2012, 2:49:47 PM4/15/12
to ronin...@googlegroups.com, gosu...@googlegroups.com
Hi Claudio,

I can't speak for Gus, who is the main guy behind Ronin, but I think the reason Ronin allows scriptlets in the view is because it uses Gosu Templates, which are a feature of Gosu and not something specific to Ronin.  They can be used in any Gosu project.

The reason Gosu Templates allows scriptlets is that sometimes you just need to encapsulate some code for your template in a function.  Yes, it can be abused, but we are all adults here, right?  

(As a side note, because of the block-based methods available on collections in Gosu, helper methods and temporary variables are less likely to be needed in applications.)

Cheers,
Carson

Claudio Tasso

unread,
Apr 15, 2012, 3:41:11 PM4/15/12
to ronin...@googlegroups.com, gosu...@googlegroups.com
Hi Carson,

thank you very much for response, I've really appreciated it.
See you


On Sunday, April 15, 2012 8:49:47 PM UTC+2, Carson Gross wrote:
Hi Claudio,

I can't speak for Gus, who is the main guy behind Ronin, but I think the reason Ronin allows scriptlets in the view is because it uses Gosu Templates, which are a feature of Gosu and not something specific to Ronin.  They can be used in any Gosu project.

The reason Gosu Templates allows scriptlets is that sometimes you just need to encapsulate some code for your template in a function.  Yes, it can be abused, but we are all adults here, right?  

(As a side note, because of the block-based methods available on collections in Gosu, helper methods and temporary variables are less likely to be needed in applications.)

Cheers,
Carson

Gus Prevas

unread,
Apr 15, 2012, 3:54:37 PM4/15/12
to ronin...@googlegroups.com, gosu...@googlegroups.com
Carson's got the gist of it.  Controller/view separation is a noble goal, but how would a templating system go about enforcing it?  I've had many painful experiences with templating languages that only allow direct value substitutions, or provide a gimped subset of the language functionality you need for things like formatting.  Often you end up with "view utility" classes chock-full of simple, sometimes single-use methods, and you lose locality of reference - model/view/controller turns into model/view/view/controller.

The idea that you need a fully-functional language in your templates - indeed, ~the same~ fully-functional language that you're using for the rest of your app - is a core philosophy of Ronin.  Of course, another core philosophy is that Ronin lets you use whatever components you're comfortable with, so there's no reason you couldn't use a more restrictive templating system instead of Gosu templates if you'd prefer. :)
Reply all
Reply to author
Forward
0 new messages