6

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'
Community
  • 1
  • 1
dimitry_n
  • 2,939
  • 1
  • 30
  • 53
  • How can we help you figure out your `image_tag` issue unless you post your code? There's no guarantee anyone can reproduce your issue without using the same input. – MarsAtomic Aug 05 '15 at 16:27
  • @MarsAtomic well, I did mention that " I am not using any variables inside my call, the image tag points to and svg " . Here is my code: `= image_tag 'hello-mars-attomic.svg'` – dimitry_n Aug 05 '15 at 16:29

3 Answers3

8

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
dimitry_n
  • 2,939
  • 1
  • 30
  • 53
5

I was using gitbash on windows,

and this worked for me,

slimrb -e foo.html.slim foo.html.erb
gogaz
  • 2,323
  • 2
  • 23
  • 31
Bilal Haider
  • 51
  • 1
  • 2
1

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 :-)

Niels Kristian
  • 8,661
  • 11
  • 59
  • 117