将html.slim视图转换为html.erb - Rails,Slim,ERB

时间:2015-08-05 15:50:38

标签: ruby-on-rails erb slim-lang

尝试 *。html.slim 视图转换为 *。html.erb 我看过这两个问题:< / p>

如果Stack Overflow的优秀人员可以帮我找出image_tag问题,我认为后一种解决方案效果最好。

我的代码(根据要求):

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

2 个答案:

答案 0 :(得分: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

答案 1 :(得分:4)

我在Windows上使用gitbash,

这对我有用,

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