helperFormatEscaper.js 372 B

12345678910111213
  1. var toValueString = require('./toValueString')
  2. var keys = require('./keys')
  3. function helperFormatEscaper (dataMap) {
  4. var replaceRegexp = new RegExp('(?:' + keys(dataMap).join('|') + ')', 'g')
  5. return function (str) {
  6. return toValueString(str).replace(replaceRegexp, function (match) {
  7. return dataMap[match]
  8. })
  9. }
  10. }
  11. module.exports = helperFormatEscaper