Created
April 2, 2015 23:17
-
-
Save progrium/8b20dd6314f3b164244a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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