Small documentation issue, forloop.parentloop missing?
brunchboy opened this issue · 8 comments
Hello again! I’m writing up my own documentation for how to use Selmer in the context of my application, and have been trying to combine the best of Selmer’s and Django’s documentation. In doing that, I noticed that there seems to be a forloop.parentloop
variable introduced by for
that is not mentioned in the Selmer documentation, but does seem to be present in a shallow scan of the source code. So my question is, does this feature actually exist and simply need to be documented? Or does it not yet exist in Selmer?
Hi, Thanks for the heads up on that. Looks like the parentloop
key isn't actually used, it likely got missed in a refactor. I just pushed an update to remove the key since it's not used.
Ah, pity, that would be a nice feature! I’ll remove it from my own docs then. Thanks for researching this.
I'm open to explicitly adding a key on the context that allows getting the parent context for the loop. How does this work in Django?
It looks like you can do things like forloop.parentloop.counter
to get at the looping context of the next-outer loop; I presume you could chain parentloop
for deeper-nested loops. This isn’t hugely important, I just thought it was a clever feature.
The way it was implemented the key pointed to the same map as forloop
key. I've updated the implementation in a way that should match the description. Can you take a look at this commit to confirm, and if it looks good to you I can cut a new release with the feature.
That new implementation looks exactly how I would have imagined implementing it. Cool!
Perfect, I just deployed 1.12.27 with the feature.
Sweet, I’ll update to that, and revert my commit that removed it from my user guide. 😄