I’m trying to send an HTML email receipt from the iphone. The receipt should have some dynamic data in it.
I would prefer to have a template .html file with {placeholders} in it that will be replaced by using something like this:
strBody = [strBody stringByReplacingOccurrencesOfString:"{name}" withString:username]
But first I need to know how to load the contents of the file into a string so I can start replacing the placeholders.
How could this be done and will this work well?
For this kind of situation I highly recommend Matt Gemmell’s open-source MGTemplateEngine. With that you create a template file of named placeholders, and pass in a dictionary of replacements where each key matches one of the placeholders. It’s very flexible. Check out the demo project for details on how to use it.