From inside article-summary.html, I need to know whether I’m being rendered as part of index.html, or some other page. Nothing I’ve tried has worked. I can’t use $.Kind, or set a variable in index.html, or use $.Scratch, or even $.URL (which works inside the range, but not once you’re in the partial).
I’m actually going several levels deep with partials to keep the styling consistent across multiple top-level templates (article-summary.html calls blogpost-header.html, which in turn calls commentlink.html), but the problem starts the moment I leave index.html.
It looks like my only option is to duplicate the entire chain of partials, so that index.html calls one set, and other list pages continue to call article-summary.html. Unless there’s something I’ve missed in the documentation (easy enough to do…).
If you say what I think you say, then variables defined in a template file (index.html) cannot be accessed in a partial (article-summary.html). Perhaps this is possible with scratch variables, but it probably will be easier to use a page variable like .RelPermalink or .Permalink like I mentioned in my previous post.
I’d already tried Scratch and .Permalink, and they didn’t work. As far as I can tell, nothing from index.html is visible once you’re inside a partial. Currently, it looks like I’d have to change all the partials into shortcodes, and then use .Parent. I haven’t tested that yet to see if there’s a significant performance penalty.
I’ve actually abandoned the idea for now, and solved my specific problem in a completely different way.
I had vaguely noticed the example in the docs, but reading it now, it sounds like you’d then wrap the parts of the partial that don’t use the passed variable in a {{with .content}} block to get the normal behavior, correct?