Presentation Pattern Catalog
3 Iteration
3-1 Iterate Element Pattern
3-1-1 Description
Iteration which contains _stag, _cont, and _etag represents to iterate the element.
This pattern is named 'Iterate Element' pattern.
3-1-2 Situation
The situation is very popular which requres to print list items. This pattern is very useful for all these situations.
3-1-3 Example Code
Presentation Data:
<table> <tr id="mark:list"> <td id="mark:item">item</td> </tr> </table>
Presentation Logic:
/* iterate element */
#list {
logic: {
for item in list
_stag
_cont
_etag
end
}
}
#item {
value: item;
}
Output Script:
<table> <% for item in list %> <tr> <td><%= item %></td> </tr> <% end %> </table>
3-1-4 Supplement
Kwartz directive kw:d="for item in list" lets you to use this pattern without presentation logic file.
See reference manual for details.
<table>
<tr kw:d="for item in list">
<td kw:d="value: item">item</td>
</tr>
</table>
3-2 Iterate Content Pattern
3-2-1 Description
Iteration which contains only _cont represents to iterate the content.
This pattern is named 'Iterate Content' pattern.
3-2-2 Situation
This pattern is very useful when creating <dl></dl> list or table which repeats several rows.
3-2-3 Example Code
Presentation Data:
<dl id="mark:list"> <dt id="mark:text">text</dt> <dd id="mark:desc">description</dd> </dl>
Presentation Logic:
/* iterate only content */
#list {
logic: {
_stag
for item in items
_cont
end
_etag
}
}
#text {
value: item.text;
}
#desc {
value: item.desc;
}
Output Script:
<dl> <% for item in items %> <dt><%= item.text %></dt> <dd><%= item.desc %></dd> <% end %> </dl>
3-2-4 Supplement
Kwartz directive kw:d=list item in list lets you to use this pattern without presentation logic file.
See reference manual for details.
<dl kw:d="list item in items"> <dt kw:d="value: item.text">text</dt> <dd kw:d="value: item.desc">description</dd> </dl>