happyninjas/lex — pull request #20 by ziggys (2011-12-12 19:55:44+00:00)
Title: Added a new feature called recursive callbacks and upgraded README

The recursive callback tag allows you to loop through a childs element with the same output as the block.

**Example**

function my_callback($name, $attributes, $content)
{
$data = array(
'url'	=> 'url_1',
'title'	=> 'First Title',
'children'	=> array(
array(
'url'	=> 'url_2',
'title'	=> 'Second Title',
'children'	=> array(
array(
'url'	=> 'url_3',
'title'	=> 'Third Title'
)
)
),
array(
'url'	=> 'url_4',
'title'	=> 'Fourth Title',
'children'	=> array(
array(
'url'	=> 'url_5',
'title'	=> 'Fifth Title'
)
)
)
)
);

$parser = new Lex_Parser();
return $parser->parse($content, $data);
}

In the template set it up as follows.

{{ navigation }}

{{ title }}
{{ if children }}

{{ *recursive children* }}

{{ endif }}

{{ /navigation }}

**Result**

First Title

Second Title

Third Title

Fourth Title

Fifth Title