25 lines
832 B
Bash
25 lines
832 B
Bash
#! /bin/bash
|
|
|
|
# This is a ver y crude templating engine build in bash
|
|
# The input files are:
|
|
# src/
|
|
# - index.dev.html
|
|
# script.js
|
|
# styles.css
|
|
#
|
|
# All these files are bundled into:
|
|
# index.html
|
|
|
|
build_dest=build/index.html
|
|
|
|
key_js_line=$(awk '/<script replaceMe><\/script>/ {print NR}' ./src/index.dev.html)
|
|
jsReplace=$(head -n $[$key_js_line - 1] ./src/index.dev.html && echo "<script>" && cat ./script.js && echo "</script>" && tail -n +$[key_js_line + 1] ./src/index.dev.html)
|
|
echo "$jsReplace" > $build_dest
|
|
|
|
key_css_line=$(awk '/<style replaceMe><\/style>/ {print NR}' ./$build_dest)
|
|
cssReplace=$(head -n $[$key_css_line - 1] ./$build_dest && echo "<style>" && cat ./styles.css && echo "</style>" && tail -n +$[key_css_line + 1] ./$build_dest)
|
|
|
|
echo "$cssReplace" > $build_dest
|
|
|
|
echo "index.html compiled into $build_dest"
|