Skip to content

Commit

Permalink
fix: upgraded deps, fixed i18n docs (closes #350)
Browse files Browse the repository at this point in the history
  • Loading branch information
niftylettuce committed Feb 20, 2019
1 parent 33f560d commit 3d339e5
Show file tree
Hide file tree
Showing 5 changed files with 852 additions and 435 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ If you do not do this, then your Pug templates will re-compile and re-cache ever

All you need to do is simply pass an [i18n][] configuration object as `config.i18n` (or an empty one as this example shows to use defaults).

> Don't want to handle localization and translation yourself? Just use [Lad][lad] – it's built in and uses [mandarin][] (with automatic Google Translate support) under the hood!

```js
const Email = require('email-templates');
Expand Down Expand Up @@ -445,20 +447,19 @@ Then slightly modify your templates to use localization functions.
> `html.pug`:

```pug
p= t(`Hi ${name},`)
p= `${t('Hi')} ${name},`
p= t('Welcome to Mars, the red planet.')
```

> `subject.pug`:

```pug
= t(`Hi ${name}, welcome to Mars`)
p= `${t('Hi')} ${name}, t('welcome to Mars')`
```

Note that if you use [Lad][], you have a built-in filter called `translate`:

```pug
p: :translate(locale) Hi #{name}
p: :translate(locale) Welcome to Mars, the red planet.
```

Expand Down Expand Up @@ -880,3 +881,5 @@ Instead of having to configure this for yourself, you could just use [Lad][] ins
[express]: https://expressjs.com

[opn-options]: https://github.com/sindresorhus/opn#options

[mandarin]: https://github.com/niftylettuce/mandarin
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com)"
],
"dependencies": {
"@ladjs/i18n": "^1.0.0",
"@ladjs/i18n": "^1.1.0",
"auto-bind": "^2.0.0",
"bluebird": "^3.5.3",
"consolidate": "^0.15.1",
Expand All @@ -31,27 +31,27 @@
},
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.2.2",
"@babel/preset-env": "^7.2.3",
"@commitlint/cli": "^7.2.1",
"@commitlint/config-conventional": "^7.1.2",
"ava": "^1.0.1",
"@babel/core": "^7.3.3",
"@babel/preset-env": "^7.3.1",
"@commitlint/cli": "^7.5.2",
"@commitlint/config-conventional": "^7.5.0",
"ava": "^1.2.1",
"cheerio": "^1.0.0-rc.2",
"codecov": "^3.1.0",
"codecov": "^3.2.0",
"cross-env": "^5.2.0",
"ejs": "^2.6.1",
"eslint": "^5.12.0",
"eslint": "^5.14.1",
"eslint-config-xo-lass": "^1.0.3",
"eslint-plugin-node": "^8.0.1",
"fixpack": "^2.3.1",
"husky": "^1.3.1",
"lint-staged": "^8.1.0",
"lint-staged": "^8.1.4",
"nodemailer-sendgrid": "^1.0.3",
"nyc": "^13.1.0",
"nyc": "^13.3.0",
"pug": "^2.0.3",
"remark-cli": "^6.0.1",
"remark-preset-github": "^0.0.13",
"xo": "^0.23.0"
"xo": "^0.24.0"
},
"engines": {
"node": ">=6.4.0"
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ class Email {
config.juiceResources = config.juiceOptions;
delete config.juiceOptions;
}

if (config.disableJuice) {
config.juice = false;
delete config.disableJuice;
}

if (config.render) {
config.customRender = true;
}
Expand Down Expand Up @@ -154,6 +156,7 @@ class Email {
const res = await readFile(filePath, 'utf8');
return res;
}

const engineName = map && map[paths.ext] ? map[paths.ext] : paths.ext;
const renderFn = engineSource[engineName];
if (!engineName || !renderFn)
Expand Down
1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ test('send mail with custom render function and no templates', async t => {
} else {
res = '';
}

return Promise.resolve(email.juiceResources(res));
},
transport: {
Expand Down
Loading

0 comments on commit 3d339e5

Please sign in to comment.