Moved tracking scripts to partial and made tools.formatMessage() less greedy
The change in tools.formatMessage() prevents stripping CSS like a[data-foo] and arrays in JS. Thus only replacing mergeTag it knows about.
This commit is contained in:
parent
1c38a1a7bb
commit
a164a7fb40
5 changed files with 41 additions and 49 deletions
|
@ -62,20 +62,26 @@ router.get('/:campaign/:list/:subscription', passport.csrfProtection, (req, res,
|
|||
}
|
||||
|
||||
let renderHtml = (html, renderTags) => {
|
||||
campaign.editorName = campaign.editorName || 'summernote';
|
||||
let sfx = '';
|
||||
if (campaign.editorName !== 'summernote' && campaign.editorName !== 'codeeditor') {
|
||||
sfx = '-raw';
|
||||
let render = (view, layout) => {
|
||||
res.render(view, {
|
||||
layout,
|
||||
message: renderTags ? tools.formatMessage(serviceUrl, campaign, list, subscription, html) : html,
|
||||
campaign,
|
||||
list,
|
||||
subscription,
|
||||
attachments,
|
||||
csrfToken: req.csrfToken()
|
||||
});
|
||||
};
|
||||
|
||||
if (campaign.editorName && campaign.editorName !== 'summernote' && campaign.editorName !== 'codeeditor') {
|
||||
res.render('partials/tracking-scripts', { layout: 'archive/layout-raw' }, (err, scripts) => {
|
||||
html = scripts ? html.replace(/<\/body\b/i, match => scripts + match) : html;
|
||||
render('archive/view-raw', 'archive/layout-raw');
|
||||
});
|
||||
} else {
|
||||
render('archive/view', 'archive/layout');
|
||||
}
|
||||
res.render('archive/view' + sfx, {
|
||||
layout: 'archive/layout' + sfx,
|
||||
message: renderTags ? tools.formatMessage(serviceUrl, campaign, list, subscription, html) : html,
|
||||
campaign,
|
||||
list,
|
||||
subscription,
|
||||
attachments,
|
||||
csrfToken: req.csrfToken()
|
||||
});
|
||||
};
|
||||
|
||||
let renderAndShow = (html, renderTags) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue