Skip to content
This repository has been archived by the owner on Mar 2, 2022. It is now read-only.

epigenesys/mail_merge

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mail_merge

Mail Merge Gem

Parses a string and replaces specified merge fields with the evaluated or specified result:

Usage
  • MailMerge.merge(content, options = {}, merge_fields = [], delimeter = “::”, allow_dynamic = false)

Examples
  • content = “Welcome to ::site.name::, ::user.full_name::!”

  • merged_content = MailMerge.merge(content, {:site_name => ‘site’,:user_name => ‘name’}, [‘::site_name::’, ‘::user_name::’]) # Basic substitution example

  • merged_content = MailMerge.merge(content, {:site => @site, :user => @user}, [‘::site.name::’, ‘::user.full_name::’]) # Simple evaluated example

  • merged_content = MailMerge.merge(content, {:site => @site, :user => @user}) # This will evaluate any merge fields that start with ‘site’ or ‘user’

  • merged_content = MailMerge.merge(content, {:site => @site, :user => @user}, [‘~~site.name~~’, ‘~~user.full_name~~’], “~~”) # Using your own delimeter

  • content = “Welcome, ::[user-1].full_name::!” merged_content = MailMerge.merge(:content => content, :allow_dynamic => true) # This will call find on any fields wrapped in [] (Ex. User.find(1).full_name) # output: “Welcome, Andrew Wiggin!”

Releases

No releases published

Packages

No packages published