2017 © Pedro Peláez
 

library email-merge

Token interpolation for email merge operations

image

utoronto/email-merge

Token interpolation for email merge operations

  • Monday, January 2, 2017
  • by bsmithlea
  • Repository
  • 1 Watchers
  • 0 Stars
  • 228 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 1 % Grown

The README.md

email-merge

PHP component for handling email templates with placeholder tokens. The email templates are assumed to be user-editable. Creating a new template requires declaring the set of allowable placeholder tokens. An exception will be thrown if the template text contains something that looks like a token but which is not expected., (*1)

Basic usage

// Define allowed token names
$tokens = new TokenSet(array("USERNAME", "FOO", "BAR"));

// Email subject line may contain tokens also
$subject = "Hello %USERNAME%";

// HTML email body
$htmlBody = <<<HTML_BODY
<p>Here is a list of interpolated values


  • Foo: %FOO%
  • Bar: %BAR%
</p> HTML_BODY; // Create a template in which all tokens must be "allowed" $tpl = new Template($subject, $htmlBody, $tokens); $parser = new Parser($tpl); $data = array( "USERNAME" => "qq12345", "FOO" => "my foo value", "BAR" => "my bar value" ); // A Parser instance will return Template objects containing interpolated values $result = $parser->getResult($data);

Unexpected token

// Define allowed token names
$tokens = new TokenSet(array("USERNAME", "FOO", "BAR"));

// token name not in allowed set
$subject = "Hello %NOT_A_LEGAL_TOKEN%";

// throws UnrecognizedTokenException
$tpl = new Template($subject, "", $tokens);

The Versions

02/01 2017

dev-master

9999999-dev

Token interpolation for email merge operations

  Sources   Download

proprietary GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Ben Smith Lea

email template interpolation

02/01 2017

0.0.3

0.0.3.0

Token interpolation for email merge operations

  Sources   Download

proprietary GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Ben Smith Lea

email template interpolation

02/01 2017

0.0.1.x-dev

0.0.1.9999999-dev

Token interpolation for email merge operations

  Sources   Download

proprietary GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Ben Smith Lea

email template interpolation

10/12 2016

0.0.2

0.0.2.0

Token interpolation for email merge operations

  Sources   Download

proprietary GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Ben Smith Lea

email template interpolation

10/12 2016

dev-user-editable

dev-user-editable

Token interpolation for email merge operations

  Sources   Download

proprietary GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Ben Smith Lea

email template interpolation

10/12 2016

0.0.1

0.0.1.0

Token interpolation for email merge operations

  Sources   Download

proprietary GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Ben Smith Lea

email template interpolation