diff --git a/packages/string-templates/src/index.js b/packages/string-templates/src/index.js index 093da977ea..7996bb9f1f 100644 --- a/packages/string-templates/src/index.js +++ b/packages/string-templates/src/index.js @@ -177,7 +177,9 @@ module.exports.isValid = (string, opts) => { const context = {} try { const instance = opts.noHelpers ? hbsInstanceNoHelpers : hbsInstance - instance.compile(processors.preprocess(string, false))(context) + instance.compile(processors.preprocess(string, { noFinalise: true }))( + context + ) return true } catch (err) { const msg = err && err.message ? err.message : err diff --git a/packages/string-templates/src/processors/index.js b/packages/string-templates/src/processors/index.js index 257dca7aec..aae18aed8b 100644 --- a/packages/string-templates/src/processors/index.js +++ b/packages/string-templates/src/processors/index.js @@ -23,9 +23,13 @@ function process(output, processors, opts) { module.exports.preprocess = (string, opts) => { let processors = preprocessor.processors + if (opts.noFinalise) { + processors = processors.filter( + processor => processor.name !== preprocessor.PreprocessorNames.FINALISE + ) + } return process(string, processors, opts) } - module.exports.postprocess = string => { let processors = postprocessor.processors return process(string, processors)