1

所以我知道这看起来很傻,但是我无法使用grunt-assemble让页面数据显示在我的布局中。我可以让页面数据显示在 page.hbs 中,并出现在布局中,但无法让 page.json 出现在 layout.hbs 中

这是相关的位,如果您需要更多信息,请告诉我。

布局/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>

数据/home.json

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

页面/home.hbs

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

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

</section>

组装输出

<!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>

如果您需要更多信息,请告诉我。我敢肯定这是非常简单的事情。

4

1 回答 1

1

所以解决方案是两件事

  1. 将车把升级到 v0.4.41(我在 0.4.0 上)
  2. 利用{{ page.title }}
于 2014-08-20T03:12:43.600 回答