Top-level Div Parsing
2005.10.04 11:41
I got an email from Zach the other day detailing some new ideas for Templation, one of which is actually brilliant and is in the works for beta3.
If you've used Templation, you are familiar with the fact that the source page's <body> contents are automatically stored in the meta array, so that a template can include the source body with the tag <%%body%%>. This state of affairs works for a lot of pages because its quite common to have a single block of content that changes per-page, with the rest of the page being navigation and other elements that can be handled via includes or widgets.
But suppose you have 2 blocks of content separated by some recurring structural markup that really belongs in the template? There are a lot of workarounds, none of them very good. In the past I've tended to include the intermediary structural markup right in the source page so that the content stays in the same file. You could also put all the extra content blocks in include files and use a widget to pull them out on a per-page basis. However, that's horrible!
The solution as proposed by Zach is to automatically parse the top level divs and put their contents into appropriately named meta elements. So, for example:
<div id="content1">Me me me me</div>
<div id="content2">'N Stuff</div>
Will be automatically added to meta elements div#content1 and div#content2. Of course the overarching body datum will still be available as well. More on this soon!


