在开发过程中,我的资产(特别是图像)与产品(我将使用CDN)有很大的不同。我写了一个这样的帮手:
Ember.Handlebars.registerBoundHelper("relative-path", function(filePath) {
return App.get("assetsStartPath") + filePath
});这个助手工作得很好,我只需要在应用程序创建中设置"assetsStartPath“。
var App = Ember.Application.create({
assetsStartPath: "http://0.0.0.0:5000/my_static_path/",
// in production will be for example "http://myapp.mycnd.com/foo/bar/img/"
...
});在我的模板里
{{relative-path "img/some_image.png"}}问题是,我想在bind-attr中使用这个助手,如下所示:
<imd {{bind-attr src="relative-path 'img/some_image.png'"}} />显然这是行不通的。我怎样才能得到我想要的结果?欢迎任何建议。
发布于 2014-11-05 13:47:09
因为不需要双向绑定,所以只需使用解束缚
ie:
<img src="{{unbound relativePath}}img/some_image.png" />https://stackoverflow.com/questions/26755561
复制相似问题