Question

First of all, forgive me if this is a silly question. I am new to assemble (started using it last week) and StackOverflow.

I'm trying to use the partial "body" twice on a layout, like this:

{{>body}}
{{>body}}

And I get the error message from the title: The partial body could not be found.

My original intention actually was to use that for selective markdown rendering, such as:

{{#is (extname page.src) "md"}}
    {{#markdown}}
        {{>body}}
    {{/markdown}}
{{else}}
    {{>body}}
{{/is}}

But in that case I get the same error when the page is not markdown.

Does this sound like a legit issue? Just trying to help, that's all. :-)

(BTW, for the selective markdown issue I just implemented a {{#markdown-if}} helper that does the job, so I don't need help getting that logic to work. I just want to help assemble in case this behavior I found sounds like a real issue.)

Était-ce utile?

La solution

This is an interesting use case... We used to register the page content as a body partial, but stopped doing that and instead use Regex to replace the {{>body}} tag with the page content. I think you should open an issue to request that we substitute all the body tags instead of just the first occurrence.

So to answer the question... Assemble does a string.replace and only replaces the first occurrence, so you'll get an error if trying to use {{>body}} twice.

Autres conseils

I was able to fix this in 0.4.12 with the initializeEngine option and changing the two {{> body }} references to just {{ body }}

See https://github.com/assemble/assemble/pull/468#issuecomment-38730532

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top