How can I specify header/footer behavior based on a specific custom_template

Hi there,

I’m trying to alter behavior of a header element based on whether a page is using a custom_template from the dropdown, e.g. where custom_template = 'custom-narrow-side-image'.

There doesn’t seem to be a straightforward way to do this without a lot of hacky workarounds, so I’m assuming I’m missing something.

Is there a preferred way to specify this? e.g. apply classes to the navbar, hide/show content, etc.

FWIW,

{{#post}}
{{#has custom_template="custom-narrow-side-image"}}
hello
{{/has}}
{{custom_template}}
{{/post}}

produces:

custom-narrow-side-image

I’d expect it to produce

hello
custom-narrow-side-image

You’ve totally lost me with your approach! Where does this snippet live?

{{#has}} doesn’t have support for testing if you’re on a custom template, not seen anyone ask that before.

If you’re inside a custom template already then you know your content is being rendered with that template.

I’m guessing you’re trying to do something with partials? Can you share a more comprehensive example of what you’re doing?

Hi, sure!

I have some color classes I’m trying to apply in a shared navigation bar partial.

I’m able to use #is to toggle modes (e.g. light, dark, dim) based on whether it’s the index page, or content… but there are some content templates (e.g. full-screen stories) that I’d want to override.

Imagine that I want nav-light for home, nav-dark for posts, and nav-dim for posts that use custom-narrow-side-image.

My navigation bar is in a partial.

Ideally, I’d love {{#is}} to accept a template name in addition to a context, so I could

// navigation.hbs
// Ideal FUTURE hypothetical state
<nav class="nav {{#is "home"}} nav-light {{else}} {{#is "custom-narrow-side-image"}} nav-dim {{else}} nav-dark {{/is}} nav-dark {{/is}}">

But for now, I’m just looking for any way to furth

// navigation.hbs
// Current sticking point
<nav class="nav {{#is "home"}} nav-light {{else}} nav-dark {{/is}}">

There doesn’t seem to be any body_class or post_class that produces markup that contains custom-narrow-side-image – at least not when it’s loaded via the “global template” (post editor dropdown).

Sorry for not 'splaining better out of the gate :slight_smile:

Tim