Advent 2019 part 18, Exploring Bootleg
Dive into yet another GraalVM based Clojure CLI tool
This post is part of Advent of Parens 2019, my attempt to publish one blog post a day during the 24 days of the advent.
With the advent of Graal it's now relatively straightforward to compile Clojure code to a compact and fast native binary, which has led to an explosion of new tools. In previous episodes I talked about Babashka, jet, and rep. Today I'll explore what looks like another interesting tool: Bootleg.
This post uses Nextjournal, a computational notebook environment with a focus on reproducibility. Go ahead and remix this notebook to run the code cells yourself.
First things first, let's install Bootleg, I'll simply follow the instructions in the README.
Bootleg's main job is being a template processing tool for building static websites. Let's try that out by adding a Hiccup template.
And running it through
So it expands Hiccup, basically acting as a Hiccup -> HTML converter. It can also take hiccup forms directly at the command line.
And these forms are evaluated, you have the full power of Clojure at your disposal thanks to Sci, the Small Clojure Interpreter that also powers Babashka.
So in a way Bootleg is just a Clojure interpreter, similar to
bb, but with two main differences: it renders the result of the expression to HTML, and it includes a whole slew of utility functions for dealing with various templating and markdown formats (markdown, mustache, ...), as well as doing file system manipulation like creating directories or symlinks, and for reading data from yaml, json, or edn.
So say you have this simple "layout" template, and you want to render some markdown into that
What I like about the approach bootleg has taken is that it gives you all the raw tools to set up your static site building, without dictating any of the specifics. It gives you all the building blocks, what you do with them is up to you!
Hi, my name is Arne (aka @plexus) and I consult companies and teams about application architecture, development process, tooling and testing. I collaborate with other talented people under the banner Gaiwan. If you like to have a chat about how we could help you with your project then please get in touch!