尝试将 *。html.slim 视图转换为 *。html.erb 。我看过这两个问题:< / p>
How can I convert html.slim to html.erb? - 从控制台调用时获取uninitialized constant
How can I convert html.slim files to html or html.erb? - 解析器在遇到第一个NoMethodError: undefined method image_tag for nil:NilClass
时会遇到= image_tag
。我在调用中没有使用任何变量,图像标记指向 svg
如果Stack Overflow的优秀人员可以帮我找出image_tag
问题,我认为后一种解决方案效果最好。
page data-id="foo-page"
.container
= image_tag 'bar.svg'
答案 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
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