shannonmoeller / gulp-hb

A sane Gulp plugin to compile Handlebars templates. Useful as a static site generator.

Home Page:http://npm.im/gulp-hb

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Front Matter in partials?

spacedawwwg opened this issue · comments

is there a way to access front matter from within a partial?

In the layout I can access {{frontMatter.title}} but when I try the same from within a partial it does not work?

I have also tried {{../frontMatter.title}} to no prevail.

Is there any way to do this at all?

Some options:

  1. Use partial parameters:
<!-- someFile.html -->
{{> somePartial title=frontMatter.title}}

<!-- somePartial.hbs -->
{{title}}
  1. Use the @file reference:
<!-- someFile.html -->
{{> somePartial}}

<!-- somePartial.hbs -->
{{@file.data.frontMatter.title}}
  1. Use the handlebars-layouts embed helper instead of the partial syntax:
<!-- someFile.html -->
{{{embed "somePartial"}}}

<!-- somePartial.hbs -->
{{frontMatter.title}}

Closing due to inactivity and no similar reported bugs. Feel free to reopen if you're still having issues!

Sorry for not responding. Using partial parameters worked for me, the @file reference didn't.

Happy using partial parameters though.