summaryrefslogtreecommitdiff
path: root/render.sh
blob: 9ad4ff82a014f83030fd84d756d798cbf7f58cba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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 <file> www/<path>/<to>/<prod>.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