所以我知道这看起来很傻,但是我无法使用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>
如果您需要更多信息,请告诉我。我敢肯定这是非常简单的事情。