section.index and section.index0 not working in the theme editor
Reproduction steps
Add Section index: {{ section.index0 }} to the top of a section
Add the section in the theme editor
Preview the section in theme editor and in theme preview
Additional info
In theme theme editor it will render Section index: and in the theme preview (storefront) it will render Section index: <index> (0 for the first section).
Is this a bug or by design?
It’s obviously mostly useful for loading related stuff, but can also be used for styling related stuff like something like a border or color for every other section. Or spacing/styling related stuff for the first section.
The Online Store Editor is optimized for fast rendering by re-rendering only the section that was updated. This means that if we provided the index, it would not be consistent. Thus, both the index and index0 are forced to be nil when rendering in the Online Store Editor. These new features should be used only for non-visual reasons like optimizing loading speed for real users.