Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new Templates collection, order workflow emails
- Loading branch information
aaronjudd
committed
Dec 12, 2015
1 parent
7b33a99
commit aab79c4
Showing
26 changed files
with
4,627 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,36 @@ | ||
# Reaction Email Templates | ||
A basic collection of email templates. | ||
# Email Templates | ||
A basic collection of Reaction email templates. | ||
|
||
``` | ||
meteor add reactioncommerce:reaction-email-templates | ||
``` | ||
|
||
Example of the implementation of templates from this package: | ||
Provides functionality to load local default email templates, or optionally load from the `Templates` collection. | ||
|
||
Typical use of the exported `ReactionEmailTemplate`: | ||
|
||
```js | ||
SSR.compileTemplate("itemsShipped", ReactionEmailTemplate("templates/orders/itemsShipped.html")); | ||
SSR.compileTemplate("<template>", ReactionEmailTemplate("<template>")); | ||
try { | ||
return Email.send({ | ||
to: email, | ||
from: `email account <${shop.emails[0].address}>`, | ||
subject: `A special message from from ${shop.name}`, | ||
html: SSR.render("itemsShipped", { | ||
from: `${shop.name} <${shop.emails[0].address}>`, | ||
subject: `${shop.name} Update`, | ||
html: SSR.render("<template>", { | ||
homepage: Meteor.absoluteUrl(), | ||
shop: shop, | ||
order: order, | ||
shipment: shipment | ||
}) | ||
}); | ||
``` | ||
## SSR | ||
This package includes `meteorhacks:ssr` which provides Server Side Rendering of templates. | ||
`meteorhacks:ssr` is implied and exports `SSR`. | ||
## Templates | ||
Templates are located in `reaction-email-templates/templates` and are named either after a workflow status, or a method that triggers their load. | ||
Templates can be defined in the `Shops.layout` and `Templates` collections, this collection can be used for customization of the default template collections, or to provide additional templates. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,34 @@ | ||
ReactionEmailTemplate = function (file) { | ||
return Assets.getText(file); | ||
/** | ||
* ReactionEmailTemplate - Returns a template source for SSR consumption | ||
* layout must be defined + template | ||
* @param {String} template name of the template in either Layouts or fs | ||
* @returns {Object} returns source | ||
*/ | ||
ReactionEmailTemplate = function (template) { | ||
check(template, String); | ||
let source; | ||
|
||
const lang = Meteor.call("shop/getLocale").locale.languages; | ||
// using layout where in the future a more comprehensive rule based | ||
// filter of the email templates can be implemented. | ||
const tpl = ReactionCore.Collections.Layouts.findOne({ | ||
template: template | ||
}); | ||
|
||
if (tpl) { | ||
const tplSource = ReactionCore.Collections.Templates.findOne({ | ||
template: template, | ||
language: lang | ||
}); | ||
if (tplSource.source) { | ||
return tplSource.source; | ||
} | ||
} | ||
let file = `templates/${template}.html`; | ||
try { | ||
source = Assets.getText(file); | ||
} catch (e) { // default blank template | ||
source = Assets.getText("templates/coreDefault.html"); | ||
} | ||
return source; | ||
}; |
File renamed without changes.
File renamed without changes.
Empty file.
Empty file.
Oops, something went wrong.