Fixing issue with isValid function found by testcase.

This commit is contained in:
mike12345567 2022-02-08 17:22:44 +00:00
parent 6199f06ea9
commit 07a285843e
2 changed files with 8 additions and 2 deletions

View File

@ -177,7 +177,9 @@ module.exports.isValid = (string, opts) => {
const context = {} const context = {}
try { try {
const instance = opts.noHelpers ? hbsInstanceNoHelpers : hbsInstance const instance = opts.noHelpers ? hbsInstanceNoHelpers : hbsInstance
instance.compile(processors.preprocess(string, false))(context) instance.compile(processors.preprocess(string, { noFinalise: true }))(
context
)
return true return true
} catch (err) { } catch (err) {
const msg = err && err.message ? err.message : err const msg = err && err.message ? err.message : err

View File

@ -23,9 +23,13 @@ function process(output, processors, opts) {
module.exports.preprocess = (string, opts) => { module.exports.preprocess = (string, opts) => {
let processors = preprocessor.processors let processors = preprocessor.processors
if (opts.noFinalise) {
processors = processors.filter(
processor => processor.name !== preprocessor.PreprocessorNames.FINALISE
)
}
return process(string, processors, opts) return process(string, processors, opts)
} }
module.exports.postprocess = string => { module.exports.postprocess = string => {
let processors = postprocessor.processors let processors = postprocessor.processors
return process(string, processors) return process(string, processors)