[GoLUG] ***SPAM*** Quick and easy way to insert line based text into a template file
Steve Litt
slitt at troubleshooters.com
Sun Mar 30 11:12:07 EDT 2025
Hi all,
There are a million ways to insert text into template files. The one in
this email post is great if you just have one or two of them, and if
the insertions are line based.
As you know, the main page of 444domains is created programatically.
And I just added a corporate Jargon Jenerator
at https://444domains.com/#jargon .
Both the domain list and the Jargon Jenerator are inserted where a
specific comment line is located. For instance, I have the following
comment in the template file:
<!-- 444jargon -->
So here's an abbreviated approximation of my technique:
cat index.template | grep -B 1000000 > index.top
cat index.template | grep -A 1000000 > index.bottom
./make_jargon_jenerator.py > index.middle
cat index.top index.middle index.bottom > index.html
By the way, for those of you who care about getting the last
millisecond out of your processes, you could also do the following:
grep -B 1000000 index.template > index.html
./make_jargon_jenerator.py >> index.html
grep -A 1000000 index.template >> index.html
I like having the intermediate files and "useless use of cat" for
debugging.
SteveT
Steve Litt
http://444domains.com
More information about the GoLUG
mailing list