grunt-contrib-handlebars - Output is different than when I run the handlebars npm task

不打扰是莪最后的温柔 提交于 2019-12-06 01:33:54

Turns out this was a problem caused by using different versions of Handlebars where the grunt-contrib-handlebars version was different then the globally installed handlebars npm module.

You could also use a function as "processName" and specify a "namespace" in Gruntfile, for example something like this if you have only one file article_snippet.handlebars in a single folder called handlebars could do the job:

    handlebars: {
      compile: {
        options: {
          namespace: 'Handlebars.templates',
          processName: function(filename) {
              var name = filenaname.split('/')[1].split('.');
              return name[0];
          },
          wrapped: true,
          commonjs: null
        },
        files: {
          "js/articles/templates.js": "handlebars/article_snippet.handlebars",
        }
      }
    },

taking inspiration from grunt-contrib-handlebars doc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!