Handlebars templates for CLIs


Handlebars templates for CLIs! Now you can groom your stash on the command line too. Now with colors!

If you're building a CLI and want to keep the nasty string manipulations out your well crafted code, use this.

First add stashed to your deps or install manually:

npm i stashed


var stashed = require('stashed');
var render = stashed({
  templateDir: "./templates"


  answer: "two",
  name: "Rich"

Inside ./templates/basics.hbs, you'll find:

{{#rainbow}}Skittles, taste the rainbow{{/rainbow}}

Which will render this in your terminal:

Inside ./templates/with_binds.hbs, you'll find:

This template has some binds:

  1 + 1 = {{answer}}

Hello {{#inverse}}{{name}}{{/inverse}}!

This will render:

render( <String::filename_of_template_wo_ext>, 
        [Boolean::strip_colors] )

Stashed uses @marak's awesome colors.js. Stashed exposes colors.js' colors and styles as Handlebars block helpers:

  • bold
  • underline
  • italic
  • inverse
  • grey
  • black
  • yellow
  • red
  • green
  • blue
  • white
  • cyan
  • magenta
  • rainbow
  • zebra
  • zalgo

To use these, all you have to do is wrap your text with {{#style}}text{{/style}}. You can nest styles too.

Go nuts, but don't forget to send me some pull requests!