Templating Systems

written by Cyx on November 28th, 2005 @ 04:46 PM

.NET / JSF tags (aka Server Tags)

Having been programming in a server-control tag based framework for over a year, it’s easy to see that for small teams, maybe server controls are a little too much. Let me give an example.

So you want to have a meta-title capable tag that’s somewhat active in the sense that it grabs a default Title for your web page, or may be configurable via a push-mechanism wherein you assign something based on the data you pulled for a specific page. An example would illustrate this.

<meta :title id="MetaTitle" default="My Home Page" />
<meta :keywords id="MetaKeywords" default="some, keywords, here" />

That’s the usual way of doing it via server tags. A lot of technology lately have been using this technology – .NET, Java Server Faces, WACT – being some of them.

But you should ask yourself, why is it done this way? Most of the arguments for this technology are :
  • designer friendly
  • IDE integration
  • maintainability
Enter Inline Code (via Rails / ERb) For a time, inline coding has seemed to be a mortal sin for me. It left the impression of unmanageable pages, and lack of model-view separation. But having learned Ruby on Rails lately, i seem to have a come to some kind of dilemma. I’ve been asking myself, are server tags really better than inline coding? After much contemplation, here are some points I have come to realize :

1) Designers never really dive into your code.

When was the last time you really left your code to designers? If your argument is that they would be able to manage it because it looks like html, I’ll disagree with you. Almost all the time, designers doesn’t really want, or feel the need for understanding this. As far as they’re concerned, they just throw you the template and they’re done with it. For example would you really say that

<asp :datagrid id="ProductList" runat="server" >

would be better than

<%= datagrid :collection => @product_list %>
(note : datagrid here is a fictional example)

2) IDE integration

I dont really rely on IDEs for HTML. Actually i hate the fact that we should rely on a particular IDE (think MS?). But if you have to rely on it, what would be the arguments for it? Autocompletion? Intellisense?

Inline coding also has autocompletion on some editors (templates). If you’ve watched rails’ 15 min video, you’ll notice it especally with the render command.


<%= rpc (Ctrl + Spacebar) for example on rad rails would spit out the macro
<%= render :partial => "item", :collection => items %>

If you’ve used templates this will be pretty familiar.

3) Maintainability

I got to be honest with this one, i don’t have enough experience with large rails projects atm. But with principles of DRY (via render partial / render component) I doubt there’d be issues regarding cascading changes.

Just my 2c

Post a comment