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>

データ/ホーム.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

したがって、解決策は2つのことでした

  1. ハンドルバーを v0.4.41 にアップグレード (私は 0.4.0 でした)
  2. 使用する{{ page.title }}
于 2014-08-20T03:12:43.600 に答える