slimDemo.mp4
Slim is a cool way to generate a potentially complex HTML block with a minimum of characters. Most often, Slim is thought of as an alternative to Ruby on Rail's ERB, however it is useful in a broad range of contexts.
When you are trying to figure out how to express HTML in Slim, however, you inevitably rerun the generation process over and over. This git project consists of a small Ruby program that launches Slim, whenever a file is modified, created or deleted within the project. This allows you to edit the Slim 'program', and view its output each time you save it.
-
Install full Ruby; this should include the development tools.
-
Clone this git repo.
-
Install dependent gems. From the cloned git repo directory, type:
$ bundle install
In some sense, this is a REPL for the Slim Language.
The video above demonstrates command-line mode running in Visual Studio Code.
-
Start a bash shell and type:
$ ./slim_explorer
The contents of
watched/template.slim
are evaluated and stored intowww/raw.html
using the keys and values stored in filewatched/scope.yaml
. -
Use the editor of your choice to modify any file in the
watched
directory. -
The contents of
watched/template.slim
are re-evaluated andwww/raw.html
is updated each time a file in thewatched
directory is saved, created or deleted. This continues until interrupted.
-
Start a bash shell and type:
$ ./slim_explorer serve
The contents of
watched/template.slim
are evaluated and stored intowww/index.html
using the keys and values stored in filewatched/scope.yaml
. -
The file
www/index.html
will be generated. Open it in your favorite web browser, either from the file, or at http://localhost:3030/index.html. This is what it looks like:
-
Use the editor of your choice to modify any file in the
watched
directory. -
The contents of
watched/template.slim
are re-evaluated andwww/index.html
is updated each time a file in thewatched
directory is saved, created or deleted.