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

Inner loops #41

Closed
NicolasSiver opened this issue Jul 7, 2015 · 4 comments
Closed

Inner loops #41

NicolasSiver opened this issue Jul 7, 2015 · 4 comments

Comments

@NicolasSiver
Copy link

I have tried different compositions, but It just does not work for me. But in the same time, I'm not sure that I'm using Templates.js properly.

For example, where can we use such references? ../something ? Can it brake inner loops?

Here is an example of sub-categories - https://github.com/NodeBB/nodebb-theme-persona/issues/92#issuecomment-118088218

It looks like, with very first ../occurrence, it exits inner loop.

@NicolasSiver
Copy link
Author

Confirming, there is a problem with ../ references, by removing them:

screen shot 2015-07-07 at 8 29 34 pm

@psychobunny do you have recommendation how to reuse same template in several places?

@psychobunny
Copy link
Collaborator

Yes you're right, ../ goes straight to root. Maybe it should go one loop up at a time, that would make more sense.

Right now though, you can still access the parent loop by using the long form: {loop1.value}, I'm pretty sure we use this in a few places in NodeBB itself

ex.

<!-- BEGIN loop1 -->
  <!-- BEGIN loop2 -->
    {loop1.value} this should work
  <!-- END loop2 -->
<!-- END loop1 -->

@NicolasSiver
Copy link
Author

Ok, but I would like to reuse templates. Most of them use ../ references. For example link.tpl from categories, so It does not work for me when it is used in: categories loop and categories.children loop in the same time.

So in current case, I should qualify references like this:

{categories.children.name} or {categories.name}.

Maybe it should go one loop up at a time

Do you plan to do this change? Because I'm not sure if you will enjoy pull request to the Persona, where only a few templates are reused ;)

@pitaj
Copy link
Member

pitaj commented Aug 26, 2017

Fixed in Benchpress

@pitaj pitaj closed this as completed Aug 26, 2017
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