This project started as a basic ColdFusion port of the mjml project. There are many similarities between thie and mjml and many of the tags are the same. However, there are also differences in some tags and rendered output.
It is used to parse a simple email markup language to simplify the process of creating responsive email templates that look great in as many email clients as possible - both mobile and desktop.
It currently supports Lucee 4.5+.
Adobe ColdFusion is not currently supported, but in theory could be if internal changes are made to use JavaLoader to initiate the required Java classes.
You need to create an instance of the emlParser.cfc. This should be treated as a transient object - you need to create a new object for each email that you want to render.
eml = new emlParser( [configuration] );
configuration
struct default=see below: a struct of configuration options used to configure certain aspects of the email render. Default values are:
{
breakPoint: 480,
compressCSS: true,
containerWidth: 600,
customTagPath: "",
lineLength: 500
}
For example:
eml = new eml.emlParser({
breakPoint: 400,
containerWidth: 700
});
Property | Default | Notes |
---|---|---|
allowIncludes | true | Set to false to disable the em-include tag |
breakPoint | 480 | The width in pixels that the css breakpoint occurs |
compressCSS | true | If set to true, the CSS gets compressed when the rendered output is minified |
containerWidth | 600 | The width in pixels used for the default width of the em-body tag |
customTagPath | A path to a directory that contains custom tags. This path should either use a mapping or be relative to the application context root | |
lineLength | 500 | The target line length used when the rendered output is minified |
To generate the HTML for your email, call the toHTML()
method:
toHTML( input [, minify, inserts] )
input
string: the emml to parse and render
minify
boolean default=false: if set to true, the HTML output is minifiedinserts
struct default={}: a struct containing keys of placeholders to replace within the rendered HTML. For example, if you passed in {test: "This is my test"}, placeholders{{:test:}}
within the rendered HTML would be replaced with 'This is my test'.
myHTML = eml.toHTML(myMarkup);
The emlParser is expecting a string comprised of 'em' tags that make up an email render. In its most basic form, this looks like:
<em-eml>
<em-body>
Hello World
</em-body>
</em-eml>
You can try the <em>
markup using our simple editor that gives a preview of the HTML output.
The following tags are available: