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

2019-03-20 20:13发布

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'

2条回答
成全新的幸福
2楼-- · 2019-03-20 20:50

I was using gitbash on windows,

and this worked for me,

slimrb -e foo.html.slim foo.html.erb
查看更多
乱世女痞
3楼-- · 2019-03-20 21:08

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
查看更多
登录 后发表回答