I have images stored in my app/assets/images directory, and from my JST templates (rendered by my Backbone view) I am trying to figure out how to get the image asset path. src='assets/images/image.png' does not work. Any ideas?
Thanks
You can try this:
var imgPath = 'app/assets/images/',
img = 'image.png',
tpl = _.template('<img src="<%- src %>">');
console.debug(tpl({ src:imgPath+img }));
Are you using rails as your backend? Then in your template file it should be:
<img src="/assets/image">
The path to retrieve assets starts with /
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.