<@ ENDLOOP @>
<@ LOOP selfLoop@>
- <@if __FIRST @><ul><@endif@><li><% __COUNTER %> <% NODE %>#<% CNT %>
+ <@if __FIRST @><ul><@endif@><li><% __COUNTER %> <% NODE %>#<% CNT %> ID:<% ^id %>
<@ SELF @>
- <@ LOOP oneloop@><@if __FIRST @><ol><@endif@><li><% __COUNTER %> oneloop:<% NODE %>#<% CNT %><@if __LAST @></ol><@endif@><@ ENDLOOP @>
+ <@ LOOP oneloop@><@if __FIRST @><ol><@endif@><li><% __COUNTER %> oneloop:<% NODE %>#<% CNT %> ID:<% ^id %><@if __LAST @></ol><@endif@><@ ENDLOOP @>
<@if __LAST @></ul><@endif@>
<@ ENDLOOP @>
- <ul><li>1 outer#1
+ <ul><li>1 outer#1 ID:23
- <ul><li>1 inner#4
+ <ul><li>1 inner#4 ID:23
- <li>2 inner#5
+ <li>2 inner#5 ID:23
</ul>
- <ol><li>1 oneloop:subloop1#2<li>2 oneloop:subloop2#3</ol>
+ <ol><li>1 oneloop:subloop1#2 ID:23<li>2 oneloop:subloop2#3 ID:23</ol>
- <li>2 outer#6
+ <li>2 outer#6 ID:23
- <ul><li>1 inner#8
+ <ul><li>1 inner#8 ID:23
- <ol><li>1 oneloop:subloop3#9</ol>
+ <ol><li>1 oneloop:subloop3#9 ID:23</ol>
- <li>2 inner#10
+ <li>2 inner#10 ID:23
</ul>
- <ol><li>1 oneloop:subloop2#7</ol>
+ <ol><li>1 oneloop:subloop2#7 ID:23</ol>
- <li>3 outer#11
+ <li>3 outer#11 ID:23
- <ul><li>1 inner#12
+ <ul><li>1 inner#12 ID:23
- <li>2 inner#13
+ <li>2 inner#13 ID:23
- <ul><li>1 innerst#14
+ <ul><li>1 innerst#14 ID:23
- <li>2 innerst#15
+ <li>2 innerst#15 ID:23
- <li>3 innerst#16
+ <li>3 innerst#16 ID:23
- <ol><li>1 oneloop:subloop4#17</ol>
+ <ol><li>1 oneloop:subloop4#17 ID:23</ol>
- <li>4 innerst#18
+ <li>4 innerst#18 ID:23
</ul>
switch (node->type) {
case LoopNode:
- freeNode( node->nodeData.loop.bodyNode );
- freeNode( node->nodeData.loop.selfNode );
+ freeNode( node->nodeData.loop.bodyNode ); /* selfNode is somewhere inside bodyNode */
GListFree( node->nodeData.loop.childrenLoop );
GListFree( node->nodeData.loop.listVarValues );
* for all other. Currently, bool values have only "true"/"false"
* string values
* <@IF EXPRESSION @>
- * <@ELSE@>
+ * [ <@ELSE@> ]
* <@ENDIF@>
*
* Expression is classical with support following:
* C-level.
*
* <@LOOP MARKNAME@>
- * <@ SELF @>
+ * [ <@ SELF @> ]
* <@ENDLOOP@>
* Loop has predefined variables:
* __FIRST - true for first iteration
* setTemplateValueBool("outerLoop.var1");
* addTemplateRow("innerLoop");
* setTemplateValueBool("outerLoop.innerLoop.var2");
+ * - addTemplateNestedLoop
+ * returnTemplateNestedLoop
+ * Manage self-nested loops ( ie tree-like structures ).
+ * Loop's template should contains one <@ SELF @> pointer.
+ *
+ * Examplaes of usage are in data/template.html used for test.
*
******************************************************************************
* Memory management *
* Unfortunatly, I'm too lazy to unify memory usage by several pieces
* in library. So, library uses mixed plain malloc and memory context
* concepts (tmalloc.h).
- * To work with library it's needed to allocate persitent memory context
- * for initTemplate() call and temprorary memory context for usual work.
+ * To work with library it's needed to allocate persistent memory context
+ * for initTemplate() call and provide temporary memory context for usual work.
* after printTemplate is called it's needed to call resetTemplate() and
* then resetMemoryContext() for second context.
*
struct {
TemplateNode loop;
LoopRow savedRowData;
- GList *childrenLoopAfterSelf;
+ GList *childrenLoopAfterSelf;
} nest;
/* LoopNode */
char *varName;
int varNameLength;
TemplateNode bodyNode;
- TemplateNode selfNode;
+ TemplateNode selfNode; /* pointer to self-nested plase to insert */
GList *childrenLoop; /* to reset loop's instance */
GList *listVarValues; /* list of loop variables */
GList *listInstance;
+->row
|
|
- +->row->nestedinstance
+ +->row->currentInstance
*/
LoopRow lastRow;
LoopInstance currentInstance;