Gruntjs 组装-无法使用(注册?)把手辅助工具
我试图创建一个非常简单的车把助手 helpers/json.jsGruntjs 组装-无法使用(注册?)把手辅助工具,gruntjs,handlebars.js,assemble,Gruntjs,Handlebars.js,Assemble,我试图创建一个非常简单的车把助手 helpers/json.js module.exports.json = function(obj) { return JSON.stringify(obj); }; Gruntile module.exports = function(grunt) { grunt.initConfig({ assemble: { options: { assets: "dist/as
module.exports.json = function(obj) {
return JSON.stringify(obj);
};
Gruntile
module.exports = function(grunt) {
grunt.initConfig({
assemble: {
options: {
assets: "dist/assets",
data: "src/data/*.json",
layoutdir: "src/layouts/",
partials: "src/partials/*.hbs",
helpers: ["src/helpers/json.js"],
flatten: true
},
page.hbs
{{{#json mydata.something }}}
但当我尝试使用它时,我会出错
Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'INVALID' Use --force to continue.
如果我在helpers/json.js中犯了语法错误,我会得到一个错误,因此它会读取文件。看起来正确的语法是
{{{json mydata.something}}}
它不起作用。看起来正确的语法是
{{{json mydata.something}}}
不是这样的