• Stars
    star
    156
  • Rank 232,167 (Top 5 %)
  • Language
    HTML
  • License
    MIT License
  • Created about 8 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Gulp workflow for building HTML emails

A Gulp Workflow for Building HTML Emails

Sample Email Template

This is a workflow for building HTML emails using Gulp. It comes with a default MailChimp-supported template.

What it does -

  1. Builds HTML email from templates and partials
  2. Compiles SCSS to CSS
  3. Inlines the inline.css file and embeds the embedded.css file
  4. Generates a preview of emails
  5. Creates a zip of the build directory for upload (optional)

Getting Started

1. Install dependencies

This workflow requires the following dependencies -

  • Node.js with npm (Install)
  • Gulp.js (Install with npm install gulp)

2. Clone this repository

git clone https://github.com/ireade/gulp-email-workflow.git
cd gulp-email-workflow

Or download as a ZIP.

3. Install packages

npm install

4. Start build

npm start

The compiled and inlined output email will be in the build/ directory. Can be previewed in browser at http://localhost:8000

How to use

Creating templates

Nunjucks is used for compiling template files to HTML.

Templates are stored in src/templates/ and partials in src/templates/partials. To create a template, create a file in the templates directory with the .nunjucks file extension.

To include a partial in your template, use the following syntax -

{% include "partials/PARTIAL_FILE_NAME.nunjucks" %}

To define a block of dynamic content to be replaced by the email file, use the following syntax -

{% block CUSTOM_BLOCK_NAME %}{% endblock %}

Creating emails from templates

To create an email based off a template file, create a new file in the src/emails/ directory (also with the .nunjucks file extension).

Specify which template to use using the following syntax -

{% extends "TEMPLATE_NAME.nunjucks" %}

To define the contents of a dynamic content block, use the following syntax -

{% block CUSTOM_BLOCK_NAME %} 
Content goes here
{% endblock %}

Working with global data

Global data is stored in the src/data directory as JSON files. Include new data files in the config section at the top of the gulpfile.js -

var globalData = {
    DATA_NAME_1: require('./src/data/FILE_NAME_1.json'),
    DATA_NAME_2: require('./src/data/FILE_NAME_2.json')
};

For example -

var globalData = {
    mailchimp: require('./src/data/mailchimp.json')
};

CSS

SASS files are stored in the src/sass/ directory. There are two main SASS files -

  • inline.scss for styles you w Liant to be inlined to their elements
  • embedded.scss for styles that shouldn't be inlined. These will be inlcluded within a <style> element in the <head>

You can create subdirectories within the SASS folder to hold any partials. Make sure to precede the name of a partial with an underscore, e.g. _reset.scss.

Generating the zip file

You can also generate a zip file of the build directory for export. You can do this by running -

npm run zip

Alternatively, you can add it to the default and watch gulp tasks to have it generated automatically.

Footnotes

More Repositories

1

formhack

A hackable css form reset
CSS
341
star
2

alix

Alix, a browser extension for a11y.css
HTML
327
star
3

caniuse-embed

📊 Embed realtime data from caniuse.com
JavaScript
320
star
4

inlinetweetjs

InlineTweet.js allows you to easily create tweetable links out of any text on a webpage
HTML
315
star
5

feature-queries-manager

🛠Toggle CSS styles within @supports blocks
JavaScript
275
star
6

Toast.js

A library for Toast messages
HTML
190
star
7

app.bitsofco.de

A Progressive Web Application for bitsofco.de
JavaScript
160
star
8

simply-notify

A simple demo application of Web Push Notifications with Firebase
JavaScript
128
star
9

form-validation-realtime

A demo of realtime form validation
CSS
128
star
10

boilerplate-service-worker

JavaScript
111
star
11

css

HTML
75
star
12

demo.bitsofco.de

Code demos from www.bitsofco.de
HTML
73
star
13

operaminitips

Development features not supported in Opera Mini, and some crowsourced workarounds for them.
CSS
71
star
14

netlify-puppeteer-screenshot-demo

JavaScript
65
star
15

custom-social-buttons

Custom, Scriptless, and Trackable Social Media Share Buttons
HTML
60
star
16

accessible-modal-dialog

An accessible modal dialog
HTML
52
star
17

openwriter

A free theme for Ghost
HTML
47
star
18

accessible-dropdown-navigation

A more accessible multi-level dropdown navigation
CSS
44
star
19

offline-first-tutorial

Repository to follow along to Ghost PWA video series
HTML
39
star
20

holy-grail-css-grid

The Holy Grail Layout using CSS Grids
CSS
38
star
21

botsofcode

A twitter bot for bitsofco.de
JavaScript
35
star
22

dotfiles

Dotfiles, configurations, and general workspace setup
Shell
31
star
23

khaledbot

Delivering Major Keys to your Slack Team
JavaScript
29
star
24

mixinbank

Some useful reusable SASS mixins
CSS
28
star
25

caniuse-embed-api

JavaScript
27
star
26

ireaderinokun.com

HTML
26
star
27

kfbpolice

JavaScript
23
star
28

bitsofcode-ghost

The Ghost theme for my blog
HTML
21
star
29

wp-inlinetweetjs

A wordpress plugin for InlineTweet.js
PHP
19
star
30

awesome-service-worker

A curated list of useful resources and tips for Service Worker
18
star
31

tictactoe

A simple JS and jQuery game of tic tac toe
JavaScript
17
star
32

bits

Snippets of things I re-use but always forget exactly how to write it
17
star
33

SeniorWebDeveloperNanodegree

My Senior Web Developer Nanodegree
16
star
34

meme-maker

A Polymer element to make memes
HTML
15
star
35

nd1309-supply-chain

Blockchain Nanodegree Project 3 - Ethereum Dapp for Tracking Items through Supply Chain
JavaScript
14
star
36

ng-designer-news

Designer News clone with AngularJS and Firebase
JavaScript
13
star
37

nd1309-private-blockchain

Blockchain Nanodegree Project 1 - Create Your Own Private Blockchain
JavaScript
12
star
38

emoj11y

An accessible emoji component
HTML
12
star
39

image-alt-quickview

Quickly view the alternative text of any image in the context menu. Simply right-click on an image.
JavaScript
12
star
40

OfflineFX-Codelab

JavaScript
11
star
41

array-methods

Demos of JavaScript Array Methods
HTML
10
star
42

ui-challenges

UI Challenges from bitsofco.de
JavaScript
10
star
43

css-selectors

Lesser Used CSS Selectors
HTML
10
star
44

caniuse-embed-polymer

A Polymer component for the (unofficial) caniuse embed
HTML
9
star
45

public-transportation-app

Project #2 for the Udacity Senior Web Developer Nanodegree
JavaScript
9
star
46

pwain2021

A demo of what we can do with PWAs in 2021
JavaScript
7
star
47

nd1309-flight-surety

Blockchain Nanodegree Project 4 - Flight Surety Project
JavaScript
6
star
48

InstaChrome

An extension for Chrome that displays Instagram posts from a tag of your choice.
JavaScript
6
star
49

operadetect

CSS
6
star
50

restaurant-reviewer

Project #3 for the Udacity Senior Web Developer Nanodegree
HTML
5
star
51

capstone-project

Project #5 for the Udacity Senior Web Developer Nanodegree
JavaScript
5
star
52

bitsofcode-pa11y

Accessibility testing for bitsofcode
5
star
53

which-vendor-prefix

CSS properties that require a vendor prefix
JavaScript
5
star
54

bluebeanieme

Add a blue beanie to a selfie of yourself for Blue Beanie Day
HTML
5
star
55

meetup-event-planner

Project #1 for the Udacity Senior Web Developer Nanodegree
JavaScript
5
star
56

helloangular

Articles on developing applications with Angular 2
CSS
5
star
57

nd1309-real-estate-marketplace

Blockchain Nanodegree Capstone Project - Real Estate Marketplace
JavaScript
5
star
58

motherduckingwebsite

A SFW version of motherfuckingwebsite.com
HTML
5
star
59

corporate-dashboard

Project #4 for the Udacity Senior Web Developer Nanodegree
HTML
5
star
60

cdsx-web-capabilities-codelab

SSA CDS Extended 2021 Web Capabilities Codelab
CSS
4
star
61

cheatsheets

HTML
4
star
62

payback

An Instagram based web app that lets you find people you follow that don't follow back
CSS
4
star
63

ng-reddit

Reddit clone using AngularJS and Firebase
JavaScript
4
star
64

viewports

Testing different meta viewport tags
HTML
3
star
65

us-substantial-presence-test-via-i94

Calculate if you're tax resident in the US using your i94 form
JavaScript
3
star
66

browser-spec-status

Links to the different browser feature statuses
3
star
67

coinpay

A sample app for the Bitcoin Masterclass Lagos 2017
CSS
3
star
68

gulp-workflow

Boilerplate gulp workflow
JavaScript
3
star
69

messenger-hunt

JavaScript
3
star
70

slackdn

A Designer News Bot for Slack
JavaScript
3
star
71

codelab-pwa-workbox

Google Codelabs - Build a PWA using Workbox
HTML
2
star
72

tic-tac-toe-2

An (updated) game of tic tac toe with Javascript
JavaScript
2
star
73

tagr

A small web app made with the Instagram API
JavaScript
2
star
74

bitsofcode-jekyll

A free theme for Jekyll
CSS
1
star
75

nd1309-star-notary

Blockchain Nanodegree Project 2 - Decentralized Star Notary
JavaScript
1
star
76

inlinetweetjs-email

JavaScript
1
star
77

pebble-js-watchface

A Watchface for Pebble Time Using Pebble.js
JavaScript
1
star
78

debugbot

JavaScript
1
star
79

viewport-units

CSS viewport units
HTML
1
star
80

testslackbot

JavaScript
1
star
81

flexbug-demo

HTML
1
star