如何在Keystone项目中使用局部函数?使用HBS作为视图引擎

时间:2018-08-28 06:38:05

标签: handlebars.js keystonejs

我的主要项目中的

hbs扩展视图文件。无法弄清楚如何使用局部函数并将其包括在内。

var keystone = require("keystone");
keystone.init({
"cookie secret": "secure string goes here",
name: "my-project",
"user model": "User",
"auto update": true,
auth: true,
views: "templates/views",
partialsDir: "templates/views/partials",
"view engine": "hbs"
});

keystone.import("models");

// Setup common locals for your templates. The following are required 
for the
// bundled templates and layouts. Any runtime locals (that should be 
set uniquely
// for each request) should be added to ./routes/middleware.js
keystone.set("locals", {
_: require("lodash"),
env: keystone.get("env"),
utils: keystone.utils,
editable: keystone.content.editable
});
keystone.set("routes", require("./routes"));

keystone.start();

这是keystone.js

我将局部放置在template / views / partials文件夹中。 并尝试通过{{>}}包含在内,但找不到部分说法。

0 个答案:

没有答案