portable perspectives

a blog about programming, life, universe and everything

A first step for Static Scaffolding

note: this article originally appeared as a preliminary note, sorry. Also I expected to complete the first work in two days but, well, university duties stepped in :/


The first step of my work is to let nitro generate static code for scaffolding a class. This is not really hard since the controller can be abstracted away in a simple way.

The approach I’m currently using is to generate a part, which in turn contains a controller, two elements for a form and a set of xhtml files for the views.

The ruby files are loaded from part/Classname.rb (should I downcase that? ) and the loader also takes care of mounting the controller at a default location of /classname.plural.

I played with the idea of generating the controller via ScaffoldingCompiler but it resulted in uber complex code for a little gain, so I settled on using a simple skeleton controller. Obviously, once I had a skeleton controller, I thought that having similar skeletons for the elements and for the loader was the logical thing to do so I did it. As for the views: at the moment this files are just taken from nitro/proto/public/scaffold but I plan to use a different approach.

I wanted to use elements in the building of the scaffolded UI, cause they generate simple view code, they are easily reused, and are easy to combine.

But I always misunderstood Elements. I thought they worked like CGIKit’s components or like a great mix of rails partials + layouts, but the fact that variables are statically bound make them much less useful. Now I think I understand why everyone is using elements just for skin.rb :( (Messing up with the compiler pipeline is something I want to avoid in scaffolded code)

So, for the next next step I’ll generate helpers in addition to the elements. This way the elements will be there as some kind of example code, and I can keep the templates simple using helpers.

I was a bad developer, and have no tests in place as for now, which is Evil, and is a problem I need to fix. But I have a preliminary patch which I’ll be posting to the nitro ML as soon as those are written and I polished the code, if you take a look please let me know what do you think.

AddThis Social Bookmark Button

Sorry, comments are closed for this article.