Markup conventions
Nephtali renders dynamic output by generating datasets and replacing content in various regions of markup according to different types of XML comments.
Below is an example of markup (in this case, an excerpt of XHTML) that contains examples of the typical XML comments used in a pipe:
<!--pipe:announcements-->
<!--view:default-->
<h3>Announcements</h3>
<ul>
<!--data-->
<li>
<h3><a href="{link}>{title}</a></h3>
<p class="postdate">{date}</p>
<p>{description}</p>
</li>
<!--data-->
</ul>
<!--view:default-->
<!--view:empty-->
<h2>Announcements</h2>
<ul>
<li>
<h3>There are no announcements at this time</h3>
<p>Check back later to see if they're available.</p>
</li>
</ul>
<!--view:empty-->
<!--view:error-->
<h2>Announcements (Error)</h2>
<ul>
<li>
<h3>We experienced an error while processing this request.</h3>
<p>Please try to view this page later</p>
</li>
</ul>
<!--view:error-->
<!--pipe:announcements-->
Pipes <--pipe:announcements-->
In Nephtali, a pipe is an object used to control the data and markup that come together to form a section of a page. To let Nephtali know which region of markup a pipe has control over, we just surround a region with the XML comments that follow the formatting convention <--pipe:name_of_pipe-->
Views <--view:default-->
Inside that comment region, there can be several different views for a particular region, each denoted by surrounding comments of the formatting convention <--view:name_of_view-->
Each pipe has 4 different views upon initialization:
- A 'default' view, rendered if all goes well.
- A 'feedback' view, rendered if any required Get, Post, Cookie, or Session variables utilized by this specific pipe were found to be invalid.
- An 'empty' view, rendered if the default view was expecting a filled Dataset, but no results were returned.
- An 'error' view, rendered if the pipe experiences an error while executing.
Data regions <--data-->
Regions within views that will be databound are surrounded by <--data--> comments.
Inside that data region, the convention is to surround the names of the Row values bound to the markup in curly braces, so if your query returned a Dataset with a Row containing a 'title' field, you'd use the markup '{title}' to let Nephtali know that value should be replaced in the markup. However, through mappings available on the individual Views, you can change what markup should be bound to a particular Row value.
Nephtali repeats the data region as many times as there are Rows in the Dataset.
Why employ this type of markup scheme?
There are 4 main reasons this approach was taken.
- Designers can easily see and control all of the markup for any particular page as a whole.
- All of the programming code is removed from the structural markup.
- It's simple and uses markup designers are already familiar with.
- It plays nicely with tools like Dreamweaver, etc.