fix: use global replace for analytics header templates (#1134)

Support replacing multiple instances of the same template variable in analytics templates
This commit is contained in:
Phil Cullen 2019-10-23 17:46:19 +01:00 committed by Nicolas Giard
parent ab8391c085
commit 7db814c7ad

View File

@ -117,7 +117,7 @@ module.exports = class Analytics extends Model {
code.bodyEnd = _.defaultTo(code.bodyEnd, '') code.bodyEnd = _.defaultTo(code.bodyEnd, '')
_.forOwn(provider.config, (value, key) => { _.forOwn(provider.config, (value, key) => {
code.head = _.replace(code.head, `{{${key}}}`, value) code.head = _.replace(code.head, new RegExp(`{{${key}}}`, 'g'), value)
code.bodyStart = _.replace(code.bodyStart, `{{${key}}}`, value) code.bodyStart = _.replace(code.bodyStart, `{{${key}}}`, value)
code.bodyEnd = _.replace(code.bodyEnd, `{{${key}}}`, value) code.bodyEnd = _.replace(code.bodyEnd, `{{${key}}}`, value)
}) })