dimitry_n
dimitry_n

Reputation: 3019

Convert html.slim views to html.erb - Rails, Slim, ERB

Trying to convert *.html.slim views to *.html.erb. I've looked at these two questions:

I think the latter solution would work best, if the good people of Stack Overflow can help me figure out the image_tag issue.

My code (as requested):

page data-id="foo-page"
  .container
    = image_tag 'bar.svg'

Upvotes: 6

Views: 6329

Answers (3)

Niels Kristian
Niels Kristian

Reputation: 8865

The solution to avoid the unexpected code from Temple is to add: -o disable_escape=true for a total of:

slimrb --rails -e -o disable_escape=true foo.html.slim > foo.html.erb

This will work :-)

Upvotes: 1

Bilal Haider
Bilal Haider

Reputation: 51

I was using gitbash on windows,

and this worked for me,

slimrb -e foo.html.slim foo.html.erb

Upvotes: 5

dimitry_n
dimitry_n

Reputation: 3019

As expected, the latter solution worked. The trick is to pass -e flag, letting the interpreter know that you're converting to erb. So the full command is:

 slimrb -e `foo.html.slim` > foo.html.erb

EDIT:

to make sure that the interperter omits unnecessary calls to Temple::Utils.escape_html((...)) before variables, you can pass the --rails flag like so:

slimrb --rails -e `foo.html.slim` > foo.html.erb

Upvotes: 8

Related Questions