views:

80

answers:

1

I'm currently working on a legacy eCommerce system front-end that has alot of duplicate HTML code.

I'm trying to find a way to abstract out the complexity almost as you would when moving the similarities between similar classes into a shared abstract base-class.

I.E. "Taking out what changes and abstracting it"

I've used Java frameworks such as Tiles to do this before, but currently I'm using Webby.

Also when previously abstracting HTML, I was writing the code from scratch and using an MVC framework, so this made things a bit easier (didn't have to compare anything with diff).

Would anyone know another term for what I am describing, or perhaps a good article on the abstraction of existing HTML code for this purpose?

+1  A: 

This particular feature isn't the best documented, but Webby has partials that allow you to write snippets of pages and include them in other pages. Create a file whose name begins with an underscore (say, "_untocaesar"), and then you can include it by doing <% render(:partial => '_untocaesar') %> with an ERB filter.

Partials can have headers to indicate processing just like normal pages can, too. So by combining a templating language like ERB and partials, you should be able to have a pretty clean factoring for your site.

This isn't a general HTML concept since HTML is really just static pages, so you can't do this without a preprocessor. It's something usually handled by the framework you are using. Tiles is one, Webby is another. Exactly how it works depends to some degree on the framework itself.

Chuck
Do you know if you can do this on multiple levels? Like a layout witin a layout?
leeand00
kudos for the "Render untocaesar" heheh :)
leeand00
You should be able to render a partial anywhere in Webby that you can write Ruby code.
Chuck