Browse Source

Ensure null or empty values don't cause raw JS to appear when executing JS HBS helper

pull/3002/head
Andrew Kingston 5 years ago
parent
commit
4174b88057
  1. 6
      packages/string-templates/src/helpers/javascript.js

6
packages/string-templates/src/helpers/javascript.js

@ -36,7 +36,11 @@ module.exports.processJS = (handlebars, context) => {
// Create a sandbox with out context and run the JS
vm.createContext(sandboxContext)
return vm.runInNewContext(js, sandboxContext)
const result = vm.runInNewContext(js, sandboxContext)
if (result == null || result === "") {
return " "
}
return result
} catch (error) {
return "Error while executing JS"
}

Loading…
Cancel
Save