Skip to content

Commit

Permalink
Insert preheaders on Postmark layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
derekrushforth committed Jun 12, 2020
1 parent de82433 commit bed6874
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,15 @@ module.exports = function(grunt) {
],
},

// Insert mustachio syntax on Postmark layout preheaders
postmarkPreheader: {
src: [`${path.dist}postmark-layouts/**/content.hbs`],
overwrite: true,
replacements: [
{ from: /({{)(.?pm:preheader.?)(}})/g, to: '\\{{#preheader}}<span class="preheader">\\{{.}}</span>\\{{/preheader}}' },
],
},

// Remove handlebars config
postmarkConfig: {
src: [`${path.dist}postmark-templates/**/content.hbs`],
Expand Down Expand Up @@ -412,6 +421,7 @@ module.exports = function(grunt) {
'copy:postmarkLayouts', // Copy Handlebars layouts to dist folder
'replace:postmarkPlaceholder', // Replace handlebars {{body}} with Postmark content placeholder
'replace:postmarkConfig', // Remove handlebars config from layouts
'replace:postmarkPreheader', // Insert mustachio syntax on Postmark layout preheaders
'assemble:postmark', // Compile handlebars templates and layouts. Mainly used for loading partials into the templates.
'inline:postmark', // Load external CSS into layouts
'replace:styleBlock', // Add properties to style block
Expand Down
1 change: 1 addition & 0 deletions dist/postmark-layouts/basic-full/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@
<![endif]-->
</head>
<body>
{{#preheader}}<span class="preheader">{{.}}</span>{{/preheader}}
<table class="email-wrapper" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
Expand Down
1 change: 1 addition & 0 deletions dist/postmark-layouts/basic/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@
<![endif]-->
</head>
<body>
{{#preheader}}<span class="preheader">{{.}}</span>{{/preheader}}
<table class="email-wrapper" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
Expand Down
1 change: 1 addition & 0 deletions dist/postmark-layouts/plain/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@
<![endif]-->
</head>
<body>
{{#preheader}}<span class="preheader">{{.}}</span>{{/preheader}}
<table class="email-wrapper" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
Expand Down
1 change: 1 addition & 0 deletions src/layouts/basic-full/content.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<body>
{{#if preheader}}<span class="preheader">{{ preheader }}</span>{{/if}}
{{ pm:preheader }}
<table class="email-wrapper" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
Expand Down
1 change: 1 addition & 0 deletions src/layouts/basic/content.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<body>
{{#if preheader}}<span class="preheader">{{ preheader }}</span>{{/if}}
{{ pm:preheader }}
<table class="email-wrapper" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
Expand Down
1 change: 1 addition & 0 deletions src/layouts/plain/content.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<body>
{{#if preheader}}<span class="preheader">{{ preheader }}</span>{{/if}}
{{ pm:preheader }}
<table class="email-wrapper" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
Expand Down

0 comments on commit bed6874

Please sign in to comment.