-3

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?

leeand00
  • 25,510
  • 39
  • 140
  • 297

1 Answers1

1

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
  • 234,037
  • 30
  • 302
  • 389