# Application-specific e-mail template engine

**URL:** <https://www.ruby-forum.com/t/application-specific-e-mail-template-engine/87768>\
**Category:** Rails\
**Created:** [March 5, 2007, 9:24pm UTC](https://www.ruby-forum.com/t/application-specific-e-mail-template-engine/87768 "2007-03-05T21:24:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubylover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@rubylover](https://www.ruby-forum.com/u/rubylover)\
**Post date:** [March 5, 2007, 9:24pm UTC](https://www.ruby-forum.com/t/application-specific-e-mail-template-engine/87768/1 "2007-03-05T21:24:51Z")

</div>

Does anyone have any experience with creating a templating system for  
e-mails sent via Rails? Here is what I’d like to do:

1. User selects “Create message” from my application
2. User selects a predefined template from dropdown list.
3. Selected template populates the message field with the template  
tags replaced with correct values (replacing \<%= @tutor.name %\> with  
John D. for example)

The issue I am running into is I am not sure if I can use standard  
RHTML or ERB templates to define the Mail templates. If I can, I am  
not sure how to replace the \<% %\> fields with the correct values on  
the fly.

If anyone has any experience with a solution like this, I am all ears.

Thanks.

- j

---

<div class="post-metadata">

**Author:** ![rubylover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@rubylover](https://www.ruby-forum.com/u/rubylover)\
**Post date:** [March 5, 2007, 9:30pm UTC](https://www.ruby-forum.com/t/application-specific-e-mail-template-engine/87768/2 "2007-03-05T21:30:52Z")

</div>

On 3/5/07, Justin W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The issue I am running into is I am not sure if I can use standard  
> RHTML or ERB templates to define the Mail templates. If I can, I am  
> not sure how to replace the \<% %\> fields with the correct values on  
> the fly.
> 
> If anyone has any experience with a solution like this, I am all ears.

I believe shopify uses Liquid templates for this. If it doesn’t,  
Liquid would still be a good fit. Executing pure ruby (erb) from  
something a user entered is usually not a good thing.

–  
Rick O.  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)

---

<div class="post-metadata">

**Author:** ![rubylover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@rubylover](https://www.ruby-forum.com/u/rubylover)\
**Post date:** [March 5, 2007, 10:07pm UTC](https://www.ruby-forum.com/t/application-specific-e-mail-template-engine/87768/3 "2007-03-05T22:07:57Z")

</div>

Thanks Rick. I will look into it.

- j
