Acquire Asset Path from JavaScript

前端 未结 6 1007
梦如初夏
梦如初夏 2021-02-18 16:17

I need to display images on an HTML5 canvas that are in the Rails asset pipeline, but I need to know the path for the asset from JavaScript. I\'m using js-routes for other parts

6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-18 16:29

    For those using HAML you can do:

    :javascript
       var assetPath = "#{asset_path('some_image.jpg')}";
    

提交回复
热议问题