So, I’ve been working on distilling an HTML maker library for beginners. Like the popup builder in the new Try Ruby. And, as I’m using it, I think something like this could be a serious contender to erb.
Here’s a scrappy initial stab at the library: webpage.rb. (Requires Builder and RedCloth.) And here’s what RedHanded’s template would roughly look like: webpage-test.rb.
Even though this is a layer on top of Builder, it’s supposed to understand common use of HTML and shortcut here and there.
No head or body tags. Once you start using divs or headings or paragraphs, you’re in bodyland.
The div method takes ids and classes in CSS notation. (div('.sidebarBox') { p 'Built upon <4>>Hobix' })
Designed to generate XHTML 1.0 Strict. Adds the doctype, xml instruction, etc.
RedCloth can be used in the headers, paragraphs, spans.
Any other ideas for making this thing easier? Stuff like changing method names to be friendlier. Adding other shortcuts. Some built-in CSS layouts perhaps?