thescientist
thescientist

Reputation: 2948

grunt assemble - page.json data not showing in layout template

So I know this seems really silly, but I just can't get page data to display in my layout using grunt-assemble. I can get the page data to display in the page.hbs, and that to appear in the layout, but just can't get the page.json to appear in the layout.hbs

Here are the relevant bits, if you need anything more, let me know.

layouts/default.hbs

<!DOCTYPE html>
<html lang="en">

  <head>
    <!-- I've tried all of these and none work -->
    <!-- <title>{{ data.title }}</title>  -->
    <!-- <title>{{ config.title }}</title>  -->
    <!-- <title>{{ this.title }}</title>  -->
    <!-- <title>{{ this.page.title }}</title>  -->
    <!-- <title>{{ page.title }}</title>  -->
    <title>{{ title }}</title>

  </head>

  <body>

    <!-- Page Output -->
    {{> body }}

  </body>
</html>

data/home.json

{
  "title": "Home Page",
  "body": "this is test text",
  "id": "home-page"
}

pages/home.hbs

<section id="{{ home.id }}">

  <h1>Hello World - {{ home.body }}</h1>

</section>

assembled output

<!DOCTYPE html>
<html lang="en">

  <head>

    <!-- <title></title>  -->
    <!-- <title></title>  -->
    <!-- <title></title>  -->
    <!-- <title></title>  -->
    <!-- <title></title>  -->
    <title></title>

  </head>

  <body>

    <title></title>

    <!-- Page Output -->
        <section id="home-page">

      <h1>Hello World - this is test text</h1>

    </section>

  </body>
</html>

If you need anymore info, please let me know. I'm sure it's something super simple.

Upvotes: 1

Views: 106

Answers (1)

thescientist
thescientist

Reputation: 2948

So the solution was two things

  1. upgrade handlebars to v0.4.41 (I was on 0.4.0)
  2. use {{ page.title }}

Upvotes: 1

Related Questions