Ok, so the subject doesn't make total sense, but I have an idea of how to
use haml to defer some of the layout decisions to an external template.
Maybe this doesn't make sense either. Here's an example.
I have a site that puts content inside pretty boxes styled with CSS.
In the haml code, it looks something like...
.box
.title Title of the box
.content
Here's where all the content goes
Which generates html
<div class='box'>
<div class='title'>"This is a test"</div>
<div class='content'>
All my content goes here
</div>
</div>
This is all fine, but the haml code has too much layout logic for my taste.
If I changed how a box were to be structured (maybe I want to use a *gasp*
table), everywhere I put something inside this logical box would need to
be modified.
I'm proposing a new special character such as ! or whatever that passes the
evaluated haml block to another template. The new haml code for the above
example would look like...
!box Title of the box
Here's where all the content goes
This really says what I mean. I want a titled box with the following
content. The previous example put too much of the required layout of having
several nested div sections in the code.
The layout logic would go into another file or block that would be rendered
inline with the same engine. In this example, there would be a file
_box.haml that looks like:
.box
.title @args[0]
.content
@content
So with this template defined of how a box is to be structured, I can then
use this !box tag throughout my thousands of .haml files without worry. If
I need to modified how the box is structured to use some new CSS style or
presentation, I only need to modify the above template.
Rather than using an external file to render the template, it might be
defined inline with the main haml code, so a single file haml source for
this might look like:
^define_template :box
.box
.title @args[0]
.content
@content
!box "Title for the box"
Content for the box
I started to look at the haml source to make this modification, but the
learning code was a little steep. The advantage this has over Rails
partials is the inclusion of the content block that can be inserted wherever
the template feels it should be put and wrapped with whatever layout is
necessary.
John
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Haml" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---