Lurker News
Cursed hacks, forcing proprietary software to do what you want through clever means, or just generally doing awful, beautiful things with technology?

Comments (499) 174 threads

Show all comments

Showing thread 83 of 174

leonheld3 replies#
`sed` text files as a replacement for templating.

In the text file you have something you want to template (or "parametrize") from an outside variable, so you name that something like @@VAR@@ and then you can sed that @@VAR@@ :-)

_bbih1 reply#
Wait, you're telling me this isn't a Best Practice™?
zblesk#
It totally is.
Semaphor#
That's how we do it. Not with sed exactly, but string replacement. One is a bull email sender that only supports VBScript, the other is C#, but the users aren't supposed (or need) to have full templating powers, so this way it's easier.
teddyh#
I think the m4 macro processor might be the more canonical way to do it. Unless you’re writing a shell script, in which case a “here-document” with embedded $VARIABLES is more straightforward.