HTML Email resources
src/ template/mustache includes/style.mustache
build/
(function () { | |
'use strict'; | |
module.exports = function(grunt) { | |
// Plugins | |
grunt.loadNpmTasks('grunt-contrib-requirejs'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-contrib-sass'); | |
grunt.loadNpmTasks('grunt-contrib-clean'); | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-inline-css'); | |
// Project configuration. | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
inlinecss: { | |
main: { | |
options: {}, | |
files: { | |
'../app/views/emails/build/activation.mustache' : '../app/views/emails/src/activation.mustache', | |
'../app/views/emails/build/template.mustache' : '../app/views/emails/src/template.mustache', | |
'../app/views/emails/build/enquiry.mustache' : '../app/views/emails/src/enquiry.mustache' | |
} | |
} | |
}, | |
jshint: { | |
options: { | |
'-W057': false, | |
'-W058': false | |
}, | |
run: ['Gruntfile.js', 'assets/main.js', 'assets/js/*.js'] | |
}, | |
sass: { | |
run: { | |
options: { style: 'compressed' }, // style: 'expanded' | |
files: { | |
'assets/style.css': 'assets/main.scss' | |
} | |
}, | |
emails: { | |
options: { style: 'compressed' }, // style: 'expanded' | |
files: { | |
'../app/views/emails/src/css/template.css':'../app/views/emails/src/scss/template.scss', | |
'../app/views/emails/src/css/activation.css':'../app/views/emails/src/scss/activation.scss', | |
'../app/views/emails/src/css/enquiry.css':'../app/views/emails/src/scss/enquiry.scss' | |
} | |
} | |
}, | |
clean: { | |
run: [ 'assets/script.min.js', 'assets/style.css' ] | |
}, | |
watch: { | |
options: { | |
livereload: true, | |
}, | |
js: { | |
files: ['assets/js/*.js', 'assets/main.js'], | |
tasks: ['jshint:run'] | |
}, | |
css: { | |
files: ['assets/style.css'] | |
}, | |
mustache: { | |
files: ['../app/views/emails/build/*.mustache'] | |
}, | |
sass: { | |
options: { livereload: false }, | |
files: ['assets/scss/**/*.scss', 'assets/main.scss'], | |
tasks: ['sass:run'] | |
}, | |
sassemails: { | |
options: { livereload: false }, | |
files: ['../app/views/emails/src/scss/*.scss'], | |
tasks: ['sass:emails', 'inlinecss'] | |
}, | |
inlinecss: { | |
options: { livereload: false }, | |
files: ['../app/views/emails/src/**/*.mustache'], // TODO: Need to add HTML as well | |
tasks: ['inlinecss'] | |
}, | |
}, | |
requirejs: { | |
run: { | |
options: { | |
baseUrl: 'assets', | |
name: "main", | |
out: "assets/script.min.js" | |
} | |
} | |
} | |
}); | |
// 1. Delete compiled .css & .js | |
// 2. jshint, compile js (requirejs), compile css (sass) | |
// 3. watch (sass, jshint both with live reload) | |
grunt.registerTask('run', | |
['clean:run', 'sass:run', 'jshint:run', 'requirejs:run', 'watch']); | |
}; | |
}()); |
<style type="text/css"> | |
/** Outlook 07, 10 Padding issue: These "newer" versions of Outlook add some padding around table cells potentially throwing off your perfectly pixeled table. The issue can cause added space and also throw off borders completely. Use this fix in your header or inline to safely fix your table woes. | |
More info: http://www.ianhoar.com/2008/04/29/outlook-2007-borders-and-1px-padding-on-table-cells/ | |
http://www.campaignmonitor.com/blog/post/3392/1px-borders-padding-on-table-cells-in-outlook-07/ | |
H/T @edmelly | |
Bring inline: No. | |
**/ | |
table td {border-collapse: collapse;} | |
/** Remove spacing around Outlook 07, 10 tables | |
More info : http://www.campaignmonitor.com/blog/post/3694/removing-spacing-from-around-tables-in-outlook-2007-and-2010/ | |
/*************************************************** | |
**************************************************** | |
MOBILE TARGETING | |
Use @media queries with care. You should not bring these styles inline -- so it's recommended to apply them AFTER you bring the other stlying inline. | |
Note: test carefully with Yahoo. | |
Note 2: Don't bring anything below this line inline. | |
**************************************************** | |
***************************************************/ | |
/* NOTE: To properly use @media queries and play nice with yahoo mail, use attribute selectors in place of class, id declarations. | |
table[class=classname] | |
Read more: http://www.campaignmonitor.com/blog/post/3457/media-query-issues-in-yahoo-mail-mobile-email/ | |
*/ | |
@media only screen and (max-device-width: 480px) { | |
/* A nice and clean way to target phone numbers you want clickable and avoid a mobile phone from linking other numbers that look like, but are not phone numbers. Use these two blocks of code to "unstyle" any numbers that may be linked. The second block gives you a class to apply with a span tag to the numbers you would like linked and styled. | |
Inspired by Campaign Monitor's article on using phone numbers in email: http://www.campaignmonitor.com/blog/post/3571/using-phone-numbers-in-html-email/. | |
Step 1 (Step 2: line 224) | |
*/ | |
a[href^="tel"], a[href^="sms"] { | |
text-decoration: none; | |
color: black; /* or whatever your want */ | |
pointer-events: none; | |
cursor: default; | |
} | |
.mobile_link a[href^="tel"], .mobile_link a[href^="sms"] { | |
text-decoration: default; | |
color: orange !important; /* or whatever your want */ | |
pointer-events: auto; | |
cursor: default; | |
} | |
} | |
/* More Specific Targeting */ | |
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) { | |
/* You guessed it, ipad (tablets, smaller screens, etc) */ | |
/* Step 1a: Repeating for the iPad */ | |
a[href^="tel"], a[href^="sms"] { | |
text-decoration: none; | |
color: blue; /* or whatever your want */ | |
pointer-events: none; | |
cursor: default; | |
} | |
.mobile_link a[href^="tel"], .mobile_link a[href^="sms"] { | |
text-decoration: default; | |
color: orange !important; | |
pointer-events: auto; | |
cursor: default; | |
} | |
} | |
@media only screen and (-webkit-min-device-pixel-ratio: 2) { | |
/* Put your iPhone 4g styles in here */ | |
} | |
/* Following Android targeting from: | |
http://developer.android.com/guide/webapps/targeting.html | |
http://pugetworks.com/2011/04/css-media-queries-for-targeting-different-mobile-devices/ */ | |
@media only screen and (-webkit-device-pixel-ratio:.75){ | |
/* Put CSS for low density (ldpi) Android layouts in here */ | |
} | |
@media only screen and (-webkit-device-pixel-ratio:1){ | |
/* Put CSS for medium density (mdpi) Android layouts in here */ | |
} | |
@media only screen and (-webkit-device-pixel-ratio:1.5){ | |
/* Put CSS for high density (hdpi) Android layouts in here */ | |
} | |
/* end Android targeting */ | |
</style> | |
<!-- Targeting Windows Mobile --> | |
<!--[if IEMobile 7]> | |
<style type="text/css"> | |
</style> | |
<![endif]--> | |
<!-- *********************************************** | |
**************************************************** | |
END MOBILE TARGETING | |
**************************************************** | |
************************************************ --> | |
<!--[if gte mso 9]> | |
<style> | |
/* Target Outlook 2007 and 2010 */ | |
</style> | |
<![endif]--> | |
</style> |
<!-- Doctype best practice use XHTML STRICT, same as Hotmail & Gmail --> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | |
<link rel="stylesheet" type="text/css" href="css/template.css" /> | |
<title>Email Title</title> | |
{{{styles}}} | |
</head> | |
<body> | |
<!-- Wrapper/Container Table: Use a wrapper table to control the width and the background color consistently of your email. Use this approach instead of setting attributes on the body tag. --> | |
<table cellpadding="0" cellspacing="0" border="0" id="backgroundTable"> | |
<tr> | |
<td> | |
<!-- Tables are the most common way to format your email consistently. Set your table widths inside cells and in most cases reset cellpadding, cellspacing, and border to zero. Use nested tables as a way to space effectively in your message. --> | |
<table cellpadding="0" cellspacing="0" border="0" align="center"> | |
<tr><td valign="top">Top Row</td></tr> | |
<tr><td valign="top">Middle Row</td></tr> | |
<tr><td valign="top">Bottom Row</td></tr> | |
</table> | |
<!-- End example table --> | |
<!-- Yahoo Link color fix updated: Simply bring your link styling inline. --> | |
<a href="http://htmlemailboilerplate.com" target ="_blank" title="Styling Links" style="color: orange; text-decoration: none;">Coloring Links appropriately</a> | |
<!-- Gmail/Hotmail image display fix: Gmail and Hotmail unwantedly adds in an extra space below images when using non IE browsers. This can be especially painful when you putting images on top of each other or putting back together an image you spliced for formatting reasons. Either way, you can add the 'image_fix' class to remove that space below the image. Make sure to set alignment (don't use float) on your images if you are placing them inline with text.--> | |
<img class="image_fix" src="full path to image" alt="Your alt text" title="Your title text" width="x" height="x" /> | |
<!-- Step 2: Working with telephone numbers (including sms prompts). Use the "mobile_link" class with a span tag to control what number links and what doesn't in mobile clients. --> | |
<span class="mobile_link">123-456-7890</span> | |
</td> | |
</tr> | |
</table> | |
<!-- End of wrapper table --> | |
</body> | |
</html> |