Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested sections with duplicate names #12

Closed
zombor opened this issue Sep 1, 2010 · 5 comments
Closed

Nested sections with duplicate names #12

zombor opened this issue Sep 1, 2010 · 5 comments

Comments

@zombor
Copy link
Contributor

zombor commented Sep 1, 2010

Ran into a problem when trying to do some recursion.

A template like this:

{{#parents}}Children of {{name}}:
{{#parents}}{{>children}}{{/parents}}
{{/parents}}

fails because it ends on the first {{/parents}} end block, causing an invalid template.

I'm trying to use this on a recursive method to display an infinitely recursive unordered list. Perhaps I'm going about this the wrong way though. Here's the code I'm working with:

http://github.com/zombor/Vendo/blob/feature%2Fproduct-categories/modules/admin/templates/admin/category/product_category_list.mustache

which gets data fed from:

http://github.com/zombor/Vendo/blob/feature%2Fproduct-categories/application/classes/model/product/category.php#L57

product_categories is a recursive array I'm trying to display.

@zombor
Copy link
Contributor Author

zombor commented Sep 2, 2010

Just a followup to this, I got my recursion working. I'm not sure if this is still a bug. It seems fairly hard to support.

@bobthecow
Copy link
Owner

It is tough to support... It definitely doesn't work with a regex based parser, for the same reason that you can't parse HTML with regex

I would prob'ly use a partial or a wrapper method (myParents()) to solve this.

@geedew
Copy link

geedew commented Nov 9, 2010

This is not just names that are the same it will also occur in this setup.
[agents] => Array
(
[people] => Array
( [0] => stdClass Object
( [names] => Array( [0] -> 'jimbo slice' ) )
)
)


{{#agents}}
{{#.}}
{{#people}}
{{#.}}
{{names}}
{{/.}}
{{/people}}
{{/.}}
{{/agents}}


You can't loop arrays of arrays if they are non-associative using implicit operator because the inner {{#.}} call will act like the outer one and cause a {{#user}} not closed error.

@bobthecow
Copy link
Owner

Recursive partial test case here: 1282b81

A test case for recursive partials with implicit iterator here: fef6234

... and a fix in dev!

I'm closing this issue. Feel free to re-open if the current dev doesn't work for you. Recursive section support will hit master in 0.4.1.

@bobthecow
Copy link
Owner

And just for fun, a few more test cases here: d026315

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants