Skip to content

Instantly share code, notes, and snippets.

@thenathanjones
Last active March 10, 2021 13:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thenathanjones/88ccf785826ef880c45d2c89d3b3ce96 to your computer and use it in GitHub Desktop.
Save thenathanjones/88ccf785826ef880c45d2c89d3b3ce96 to your computer and use it in GitHub Desktop.
Simple templating script for inserting SSI tags back in the minified HTML
#!/bin/bash
ssiFile=infra/ssi.txt
indexFile=build/index.html
tempDirectory=tmp
tempFile=$tempDirectory/index.html
mkdir -p $tempDirectory
awk 'NR==FNR{rep=(NR>1?rep RS:"") $0; next} {gsub("<ssi/>",rep)}1' $ssiFile $indexFile > $tempFile && mv $tempFile $indexFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment