ruby-eco icon indicating copy to clipboard operation
ruby-eco copied to clipboard

Allow ERB templating in combination with Eco templates

Open jonhyman opened this issue 13 years ago • 5 comments

A lot of my Eco templates in Rails have an image in them. Ideally, I'd love to name my file template.js.eco.erb and be able to use <%= image_tag ... %>. However, due to the template syntax being the same, this won't work.

Is there a recommended way to do this? Should I switch off ERB to Haml or some other templating engine?

jonhyman avatar May 09 '12 13:05 jonhyman

I've also been wanting to do this, but never got to looking any closer at it. For now, I just pass down the URL when rendering the templates. It works, but doesn't feel quite right.

mattiassvedhem avatar Aug 30 '12 09:08 mattiassvedhem

+1 same problem here.. would like to use <%= asset_path ... %> tags but isn't possible yet. Some workaround is to name the file jst.erb.eco and use <%%= asset_path ... %> instead, but as @yeggeps said it doesnt feel right.

mateusmaso avatar Sep 03 '12 19:09 mateusmaso

The file ending should be .eco.erb. Everything within <% %> is handled by ERB, whereas everything within <%% %> is handled by Eco:

<%= image_tag('icon.png') %>
<%%= @eco_variable %>

This is because ERB replaces <%% with <% which is then processed by Eco as usual.

sos4nt avatar Oct 02 '12 11:10 sos4nt

Awesome @sos4nt will try that. Thanks.

mattiassvedhem avatar Oct 02 '12 11:10 mattiassvedhem

what if I wanted to do something like

<%= text_field_tag 'title', '<%%= @title %>' %>

currently this doesn't work

dougvk avatar Nov 14 '13 20:11 dougvk