Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mjmlio/gulp-mjml
Add Gulp to your MJML workflow!
https://github.com/mjmlio/gulp-mjml
email emails gulp html mjml responsive-email
Last synced: 4 days ago
JSON representation
Add Gulp to your MJML workflow!
- Host: GitHub
- URL: https://github.com/mjmlio/gulp-mjml
- Owner: mjmlio
- License: mit
- Created: 2016-01-28T16:26:48.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T16:21:29.000Z (almost 2 years ago)
- Last Synced: 2024-05-01T13:20:06.899Z (7 months ago)
- Topics: email, emails, gulp, html, mjml, responsive-email
- Language: JavaScript
- Size: 277 KB
- Stars: 162
- Watchers: 12
- Forks: 37
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gulp MJML
Add MJML to your gulp workflow!
## Usage:
> With an MJML file named `test.mjml`, render your emails to an html folder:
```javascript
const gulp = require('gulp')
const mjml = require('gulp-mjml')gulp.task('default', function () {
return gulp.src('./test.mjml')
.pipe(mjml())
.pipe(gulp.dest('./html'))
})
```> If you have custom components linked to your own `mjmlEngine`, you can pass it to the gulp task so it uses your engine to render the html:
```javascript
const gulp = require('gulp')
const mjml = require('gulp-mjml')// Require your own components if needed, and your mjmlEngine (possibly with options)
// require('./components')
const mjmlEngine = require('mjml')gulp.task('default', function () {
return gulp.src('./test.mjml')
.pipe(mjml(mjmlEngine, {minify: true}))
.pipe(gulp.dest('./html'))
})
```> If you'd like to get validation errors and , use `strict` and a custom error handler function. _Note that using `strict` will not render the file in case of error_:
```javascript
const gulp = require('gulp')const mjml = require('gulp-mjml')
const mjmlEngine = require('mjml')function handleError (err) {
console.log(err.toString());
this.emit('end');
}gulp.task('default', function () {
return gulp.src('./test.mjml')
.pipe(mjml(mjmlEngine, {validationLevel: 'strict'}))
.on('error', handleError)
.pipe(gulp.dest('./html'))
})
```> If you want to override the default file extension that is output use `fileExt`
```javascript
const gulp = require('gulp')
const mjml = require('gulp-mjml')const mjmlEngine = require('mjml')
gulp.task('default', function () {
return gulp.src('./test.mjml')
.pipe(mjml(mjmlEngine, {minify: true, fileExt: ".txt"}))
.pipe(gulp.dest('./html'))
})
```