I have a rails 4 app where I have some Javascript that generates a .jst.ejs template that looks like:
<!--name.jst.ejs which is in assets/javascripts/templates-->
<input type="text" name="store[name]" placeholder="Store Name" />
then I have a rails partial ( called _name.html.erb in my views directory) that looks like:
<input type='text' name="store[name]" value="<%= @store.name%>" />
What I'm trying to do is to keep this DRY, and only have to use the one ejs file (instead of having basically a duplicated .ejs and .erb file).
Is there a way to:
- Call an ejs file as a rails partial: eg something like:
<%= render "name" %>(which renders the name.jst.ejs file? - Also, because the two files are somewhat different, is there a way to differentiate the code if it was rendered as ejs vs erb? For example, something like:
<input type='text' name="store[name]" <% if erb %> value="<%= @store.name %>" <% else %> placeholder="Store Name" <% end %> />