aschmolck / shab

shab templating language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

shab templating language

Build Status

One day, @roberth and @zimbatm were tired of manually replacing variables with sed. What if they could just drop variables in the file and have bash do the substitution for them? Get the full power of the bash variable expansion, brilliant!

Thus was born the shab templating language. Minimal size, maximum power (assuming bash is already installed).

$ wc -l shab
24 shab

SECURITY WARNING: only use templates that you trust! The template really does have all the power of a shell script.

Example

Input:

$ cat example.sha
Hello,

this is a shab templating example.

Usage: ./shab example.shab

Your hostname: $(hostname)
Your user: ${USER:-unknown}

Output:

$ shab example.shab
Hello,

this is a shab templating example.

Usage: ./shab example.shab

Your hostname: x1
Your user: zimbatm

Nix

Of course you want to use this in your Nix expressions!

with import <nixpkgs> { overlays = [ (import ./overlay.nix) ]; };
runShabText
  "\${GREETING}\${TARGET:+, }\${TARGET}"
  { GREETING = "Hello"; TARGET = "world"; }

Template format

Basically anything that bash can do.

Dependencies

  • bash

Related projects

  • envsubst from the gettext package
  • manually replacing variables with sed

Credits

  • The authors of the UNIX V7 shell
  • Richard Stallman, GNU, and bash maintainers for their reimplementation
  • Our source of inspiration, Rube Goldberg

About

shab templating language

License:The Unlicense


Languages

Language:Nix 65.2%Language:Shell 34.8%