Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

`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@@ :-)



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.


Wait, you're telling me this isn't a Best Practice™?


It totally is.


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: