You are not logged in.
Hi all,
I hope this is the right place for a basic help like this. I'm really unexperienced coder.
I'm trying to create a program that allow me to create template of pre-formatted mail.
An example is:
To: sdasad
CC: sadsa
CCN: dsadsa
Dear [customer],
dsadsadsa
dsadsadsa in [date] sdsadsadsa
sadsadas our [product] dsadsa [price]
cheers mate
i'll use this template in my program to easily send mail with just editing the fields in [].
How do you suggest me to save this template? INI maybe? or XML? or there is any other format that could suite best? plain txt file maybe?
thanks
Nico
Offline
I'd say plain text. Then just use sed/awk to replace the placeholders with the needed content. Or depending on your implementation, you could just use shell/environment variables for all those fields, then the templace content would just be plain text in the script that would be cat'ed or echoed:
#!/bin/bash
cat << EOF
To: $ADRESSEE
CC: whatever
CCN: whateverelse
Dear $CUSTOMER,
blah
whatever whatever $DATE morestuff whatever ...
EOF"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
This is neither ini nor xml formatted data. Of course it is plain text, but since you are defining some templating rules, it a custom text format. You might want to use an extension like .template. If you absolutely must use something that already exists, you can look for an existing templating library for your chosen programming language, for c there is e.g. ctpl in the community repository.
Edit: For a simple bash script Trilby has the right idea.
Last edited by progandy (2014-09-30 17:53:21)
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |
Offline