【问题标题】:Using connect-assets with Express to precompile Handlebar templates使用 Express 的 connect-assets 预编译 Handlebar 模板
【发布时间】:2013-12-13 17:58:34
【问题描述】:

我在 Ember 项目中使用 Express,connect-assets。我坚持使用connect-assets 正确预编译车把模板。

我已经这样配置快递:

app.use(assets({
  src: app_root + 'app',
  buildDir: './public',
  jsCompilers: {
    hbs: hbsAssets
  }
}));

hbsAssets 是:

module.exports = {
  match: /\.js$/,
  compileSync: function(sourcePath, source) {
    var match = sourcePath.match(/^.*\/app\/js\/templates\/(.+)\.hbs/)
    , templateName = match[1];

    var filename = path.basename(sourcePath, '.hbs')
    , js = handlebars.precompile(source).toString();

    return 'Ember.TEMPLATES' + '["' + templateName + '"] = Handlebars.template(' + js + ');';
  }
};

问题是只有 hbs 布局被渲染,{{outlet}}s 没有被插入。

任何帮助将不胜感激

【问题讨论】:

    标签: ember.js express handlebars.js connect-assets


    【解决方案1】:

    最后我最终使用了 https://npmjs.org/package/ember-template-compiler 。它开箱即用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-28
      • 2015-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多