From 8170b6616c13828b434e0103b362ca0e056309d0 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Wed, 30 Dec 2020 19:20:36 +0100 Subject: Add template machinery *Of course* it's going to be an ugly Bash script. Is there anything else? --- build.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 build.sh (limited to 'build.sh') diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..62487bd --- /dev/null +++ b/build.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -eu + +input=$1 +output=$2 + +parameters=${input/%.html/.sh} + +if ! test -f ${parameters} +then + cp ${input} ${output} + exit +fi + +cp template.html ${output} +. ${parameters} + +sed -i s/'{TITLE}'/"${title}"/ ${output} + +link_stylesheets='' +for s in "${stylesheets[@]}" +do + link_stylesheets+=$(printf '\n' "${s}") +done + +sed -i /'{STYLESHEETS}'/'c\'"${link_stylesheets}" ${output} + +if test "${current_div}" +then + sed -i s"${current_div}" ${output} +fi + +sed -i -e /'{MAIN}'/"r ${input}" -e /'{MAIN}'/'c\' ${output} -- cgit v1.2.3