Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
render-template() {
declare filename="$1"; shift
local script k v
for var in "$@"; do
IFS='=' read k v <<< "$var"
script="s/\$\$$k/${var##${k}=}/;$script"
done
cat "$filename" | sed "$script"
}
# usage: render-template /path/to/template foo=bar baz=qux
# replaces $$foo and $$baz in template to values bar and qux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment