Question

I am using slim for a project outside rails. I see that slimrb gives options to compile the templates to html from command line.

1) However is there a way to compile a complete view directory to html. 2) Also is it possible to watch for changes and, continuously update the generated html, like what compass does for .scss files.

Was it helpful?

Solution

1) To compile all files in a directory from slim to html cd into it and type slimrb * and then hit tab to expand * into all filenames in that directory. Since it is a view directory there should be no other files then *.slim

2) Slim itself doesn't imlement this, but it shouldn't be too hard to write a script which listens for filesystem events and triggers based on which file was changed the slimrb executable.

OTHER TIPS

There are actually two complete solutions to this problem! Both are quite easy to implement:

The Slim Guard plugin

  • Every Ruby developer should know about Guard. It's the easiest way to automatically transpile files.
  • There are actually two Slim guards on GitHub, and unfortunately the main one is older and not as good. I would recommend using indrekj/guard-sim (the one I linked to).

The RubyMine IDE by JetBrains

  • Truly exceptional software, RubyMine is heaven for Rubyists. It has built-in file watchers that you can configure on a per-project basis for transpiling all your typical assets. It's simple to set up a watcher for the Slim files using the slimrb program, and you're provided with a slew of customization options.
  • In RubyMine, you can import/export file watcher configurations; I host a few here, including one for Slim.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top