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 console
How 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.
page data-id="foo-page"
.container
= image_tag 'bar.svg'
Start a new pen. Choosing Slim as your HTML Markdown language. Paste in your Slim - then click the view compiled button in your HTML pane. You'll see the straight HTML version of your markup.
erb" that means it's an HTML file with ruby code embedded in it and it is similar to ". rhtml" extension of rails file.
What's Slim? Slim is a page-templating language that minimizes markup and syntax. It removes most of the extra "programming-like" symbols from HTML so that your code looks cleaner. Slim also adds if-else statements, loops, includes, and more.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With