在我的资产(特别是图像)的开发路径中,与生产(我将使用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'"}} />
显然,这不起作用。 我怎样才能获得我想要的结果? 欢迎任何建议
答案 0 :(得分:0)