forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Email: Mark HTML comments as "safe" in email templates (grafana#64546)
- Loading branch information
1 parent
48f5825
commit ed82f96
Showing
13 changed files
with
304 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
build: build-html build-txt | ||
build: clean build-mjml build-grunt | ||
|
||
build-html: | ||
clean: | ||
rm -rf dist/ | ||
mkdir dist/ | ||
|
||
build-mjml: | ||
npx mjml \ | ||
--config.beautify true \ | ||
--config.minify false \ | ||
--config.validationLevel=strict \ | ||
--config.keepComments=false \ | ||
./templates/*.mjml --output ../public/emails/ | ||
./templates/*.mjml --output ./dist/ | ||
|
||
build-txt: | ||
build-grunt: | ||
npx grunt | ||
|
||
.PHONY: build build-html build-txt | ||
.PHONY: clean build build-mjml build-grunt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
default: | ||
- 'clean' | ||
- 'assemble' | ||
- 'replace' | ||
- 'copy' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,45 @@ | ||
module.exports = { | ||
dist: { | ||
overwrite: true, | ||
src: ['dist/*.txt'], | ||
replacements: [ | ||
{ | ||
from: '[[', | ||
to: '{{', | ||
}, | ||
{ | ||
from: ']]', | ||
to: '}}', | ||
}, | ||
], | ||
}, | ||
module.exports = function () { | ||
'use strict'; | ||
|
||
return { | ||
txt, | ||
comments, | ||
}; | ||
}; | ||
|
||
const txt = { | ||
overwrite: true, | ||
src: ['dist/*.txt'], | ||
replacements: [ | ||
{ | ||
from: '[[', | ||
to: '{{', | ||
}, | ||
{ | ||
from: ']]', | ||
to: '}}', | ||
}, | ||
], | ||
}; | ||
|
||
/** | ||
* Replace all instances of HTML comments with {{ __dangerouslyInjectHTML "<!-- my comment -->" }}. | ||
* | ||
* MJML will output <!--[if !mso]><!--> comments which are specific to MS Outlook. | ||
* | ||
* Go's template/html package will strip all HTML comments and we need them to be preserved | ||
* to work with MS Outlook on the Desktop. | ||
*/ | ||
const HTML_SAFE_FUNC = '__dangerouslyInjectHTML'; | ||
const commentBlock = /(<!--[\s\S]*?-->)/g; | ||
|
||
const comments = { | ||
overwrite: true, | ||
src: ['dist/*.html'], | ||
replacements: [ | ||
{ | ||
from: commentBlock, | ||
to: `{{ ${HTML_SAFE_FUNC} \`$1\` }}`, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.