mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Email: Mark HTML comments as "safe" in email templates (#64546)
This commit is contained in:
@@ -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\` }}`,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user