Does anyone know how to access the image_tag rails helper from within a liquid drop ?
Any help / examples would be great as i can't seem to find this anywhere!
than开发者_JAVA技巧ks rick
You mean the Liquid Template engine right?
If so, by design, the image_tag
helper is entirely unavailable from within Liquid templates. This is the express purpose of Liquid, you aren't able to execute any Ruby code on the server running Liquid, just the set of helpers that it provides you.
If you are making a Shopify store or something like this where you are using Liquid on someone else's servers, then you are stuck manually doing what the image
tag helper does normally. You have to write out <img src="{{ something.url }}>
.
If you are making or running your own Rails application which uses Liquid, you can add your own image_tag
style filter to Liquid so that its available for use in all your templates.
See Liquid for Programmers on the Github wiki.
Hope this helps!
精彩评论