set -ex; function injectTemplate { tmpl=$1 dest=$2 key=$(basename ${tmpl} .html) sed -i "/[{]${key}[}]/r ${tmpl}" $dest sed -i "s/[{]${key}[}]//g" $dest } if [ $# -ne 2 ]; then echo "Usage: ./render.sh www///.html" exit 1; fi FILE=$1 DEST=$2 mkdir -p $(dirname $DEST) cp $FILE $DEST for tmpl in templates/*.html; do injectTemplate $tmpl $DEST done for tmpl in entries/*.html; do injectTemplate $tmpl $DEST done