优化器和Handlebars客户端玉模板

时间:2013-01-07 15:16:37

标签: javascript requirejs handlebars.js optimization

尝试优化使用客户端jade模板的客户端脚本时遇到问题。最初,我遇到Require.js + Backbone optimization中描述的错误,但之后我删除了"文本"来自路径配置的模块,将其添加到排除并使text.js在本地可用。执行此操作后,我收到一个错误,其中optmizer尝试解析传递给文本模块的参数。

这是我的客户端模板:

define([
'Handlebars',
'text!/templates/product/something.jade'
], function(Handlebars, txtSomething) {
   var template = Handlebars.template, 
       templates = Handlebars.templates = Handlebars.templates || {};

   templates['something'] = Handlebars.compile(txtSomething);
});

然后是优化器配置:

({
  baseUrl: ".",
  name: "product",
  out: "product.js",
  paths: {
    Handlebars: "empty:"
  },
  exclude: ["text"]
})

我得到的错误:

Error: ENOENT, no such file or directory 'C:\templates\product\something.jade'
In module tree:
  product
    modules/something
      templates/something
        text

有关如何解决问题的建议吗?

1 个答案:

答案 0 :(得分:0)

我在运行优化之前预先编译了把手模板。删除文本引用

相关问题