Inner content in partial

Is it possible to have “inner” content in a partial, in the same manner that a shortcode uses it?

I have a partial called section.html. This partial will always have a headline, but sometimes there is differing html content that goes along with this headline - it’s not standardized enough to use if/else statements.

The first example is how I am currently accomplishing this, the second example is what I am trying to see is possible and would be preferred if possible

Example 01 - how I am doing it

partials/section.html

<section>
    <div class="container">
        <h1>{{ .headline }}</div>
        {{.inner}}
    </div>
</section>

layouts/index.html

...

{{ $hl := "This is my headline"}}
{{ $m := `
    <b>Markup goes here</b>
` }}
{{ partial "section" (dict "headline" $hl "inner" $m) }}
...

Example 02 - how I’d like to do it

partials/section.html

<section>
    <div class="container">
        <h1>{{ .headline }}</div>
        {{.Inner}}
    </div>
</section>

layouts/index.html

...

{{ $hl := "This is my headline"}}
{{ partial "section" (dict "headline" $hl) }}
    <div class="foo">
        <h2>This markup can get complex</h2>
    </div>
{{ /endpartial }}
...

Thank you

Welcome to the forum quoid! :wave:

Not that I know of. I did find a feature request for it from some while ago, in which Bep (Hugo’s lead developer) mentioned this isn’t possible with Go (the language the Hugo software is written in).

But perhaps things have changed since then. :slightly_smiling_face:

Thanks for the reply Jura.

But perhaps things have changed since then. :slightly_smiling_face:

That’s what I am wondering as well.

It’s not possible. I wish it was.

1 Like

That’s what I needed to know. Thanks for the reply, bep.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.