问题
Trying to convert *.html.slim views to *.html.erb. I've looked at these two questions:
How can I convert html.slim to html.erb? - getting
uninitialized constant
when called from the consoleHow can I convert html.slim files to html or html.erb? - parser hits a
NoMethodError: undefined method image_tag for nil:NilClass
when it comes across the first= image_tag
. I am not using any variables inside my call, the image tag points to and svg
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'
回答1:
I was using gitbash on windows,
and this worked for me,
slimrb -e foo.html.slim foo.html.erb
回答2:
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
来源:https://stackoverflow.com/questions/31837220/convert-html-slim-views-to-html-erb-rails-slim-erb