如何在 express.js 中使用 handlebars-helpers 库?
How can I use handlebars-helpers library in express.js?
我目前使用 hbs as template engine in express.js. I think the handlebars-helpers 库非常有用。
但我不知道如何集成这个库。
我也没有找到使用说明。
提前致谢。
这是因为它非常简单。复制 lib
文件夹 here 并在需要时将 handsontable.js
添加到您的项目中。
他们向您展示了如何在 lib 文件夹中的 index.js 文件中使用它。
//Usage
var handlebars = require('handlebars');
首先安装它:
$ npm i handlebars-helpers
接下来,将其添加到您的 Express 应用中(可能在模板引擎配置之前):
var Handlebars = require('hbs').handlebars;
require('handlebars-helpers').register(Handlebars, {});
这仅在您的应用程序目录包含 package.json
文件(可能包含空对象,{}
,但它必须存在)时才有效。
我目前使用 hbs as template engine in express.js. I think the handlebars-helpers 库非常有用。
但我不知道如何集成这个库。 我也没有找到使用说明。
提前致谢。
这是因为它非常简单。复制 lib
文件夹 here 并在需要时将 handsontable.js
添加到您的项目中。
他们向您展示了如何在 lib 文件夹中的 index.js 文件中使用它。
//Usage
var handlebars = require('handlebars');
首先安装它:
$ npm i handlebars-helpers
接下来,将其添加到您的 Express 应用中(可能在模板引擎配置之前):
var Handlebars = require('hbs').handlebars;
require('handlebars-helpers').register(Handlebars, {});
这仅在您的应用程序目录包含 package.json
文件(可能包含空对象,{}
,但它必须存在)时才有效。