Slim Language Explorer
November 12, 2023 ยท View on GitHub
https://user-images.githubusercontent.com/485818/155521347-856ca755-cb89-4bc7-97ce-fa69d091cf7a.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.
Installation
-
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
Slim Language REPL
In some sense, this is a REPL for the Slim Language.
Command-line Mode
The video above demonstrates command-line mode running in Visual Studio Code.
-
Start a bash shell and type:
$ ./slim_explorerThe contents of
watched/template.slimare evaluated and stored intowww/raw.htmlusing the keys and values stored in filewatched/scope.yaml. -
Use the editor of your choice to modify any file in the
watcheddirectory. -
The contents of
watched/template.slimare re-evaluated andwww/raw.htmlis updated each time a file in thewatcheddirectory is saved, created or deleted. This continues until interrupted.
Web Server Mode
-
Start a bash shell and type:
$ ./slim_explorer serveThe contents of
watched/template.slimare evaluated and stored intowww/index.htmlusing the keys and values stored in filewatched/scope.yaml. -
The file
www/index.htmlwill 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
watcheddirectory. -
The contents of
watched/template.slimare re-evaluated andwww/index.htmlis updated each time a file in thewatcheddirectory is saved, created or deleted.