How to convert slim to html?

4.3k views Asked by At

I am new to ruby gems and I have tried to find information about how to compile slim to html. There is a slimrb command, but it did not work. How do I convert a slim file to a html file?

2

There are 2 answers

1
Shouichi On

I assume local variables are missing. In that case, give them with -l option. For example,

$ cat template.slim
div
  p= message
$ slimrb template.slim -l '{"message": "hello"}'
<div><p>hello</p></div>
0
egwspiti On

Shouichi's answer is what you're looking for.

However from your comment, I understand you also want to redirect the output to a file (the .html file). The way this can be done depends on the shell you're using. For example in (ba)sh you could do it like this:

slimrb template.slim -l '{"message": "hello"}' > template.html