My goal is to enable responsive image sizes, where the sizes item is context-aware. First, I have a gallery.html shortcode that defines a number of columns for image galleries:
This works properly on one website, not on the other. On the other, the scratch key "columns" seems to be created and deleted in gallery.html shortcode before its .Inner gets evaluated (in any case, its value is empty). The thing is, there can be more than one gallery per page, and the columns value needs to be properly scoped to the relevant gallery. What could be the problem here ?
Yes, sorry, this is the gutted example where the upmost {{ .Inner }} is directly Markdown. In some other examples, {{ .Inner }} contains another nested shortcode (like figure). The logic is the same: I want to share a variable inside the context of the upmost shortcode.
I’m rendering using hugo server --disableFastRender on both websites (the working on and the un-working one).
Here’s an attempt to create a minimal reproducible example based on your description.
git clone --single-branch -b hugo-forum-topic-48968 https://github.com/jmooring/hugo-testing hugo-forum-topic-48968
cd hugo-forum-topic-48968
hugo server
I don’t either, your example works here. As is my other website.
Somehow, something is messing with my .Page.Scratch or .Page.Store states here, but I have checked and bypassed all calls to these methods and nothing fixes it.
I use deep nesting only on the homepage, to define content blocks that comply with responsive layouts and breaking points. Basically, in that context, shortcodes become reusable HTML macros that prevent from copy-pasting lots of <div class="d-none d-lg-flex flex-none shadow-sm etc...."> in the Markdown content.