Search code examples
assemble

Data within assemble markdown helper?


I’ve been using assemble (v0.24.3) for a while now and have just noticed that a feature that previously worked now appears not to - namely being able to put data (such as {{title}}) inside of the markdown helper that assemble provides.

Is there a way to do this in the latest version of assemble?

As a use case - I used to use this to prefix site urls with a certain strings when pushing to github pages, as it needed a slightly more specific base url path, but now that data variable just looks like it gets ignored when rendered.


Solution

  • handlebars will create a new "scope" or "depth" when the context inside a block helper is different than the surrounding context. In newer versions of assemble, the context is added from assemble data for use inside block helpers, which causes handlebars to create a new depth. To ensure that you're using the "parent" depth from inside the block helper, you should use the {{../}} syntax:

    {{#markdown}}
    # {{../title}}
    {{/markdown}}