2021-01-26 06:08:21 +13:00
|
|
|
const _ = require("lodash")
|
2021-01-22 00:30:53 +13:00
|
|
|
const ALPHA_NUMERIC_REGEX = /^[A-Za-z0-9]+$/g
|
|
|
|
|
2021-01-26 07:14:45 +13:00
|
|
|
module.exports.FIND_HBS_REGEX = /{{([^{].*?)}}/g
|
2021-01-22 00:30:53 +13:00
|
|
|
|
2021-05-04 22:32:22 +12:00
|
|
|
module.exports.isAlphaNumeric = char => {
|
2021-01-22 00:30:53 +13:00
|
|
|
return char.match(ALPHA_NUMERIC_REGEX)
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports.swapStrings = (string, start, length, swap) => {
|
|
|
|
return string.slice(0, start) + swap + string.slice(start + length)
|
|
|
|
}
|
|
|
|
|
2021-05-04 22:32:22 +12:00
|
|
|
module.exports.removeHandlebarsStatements = string => {
|
2021-02-04 02:04:19 +13:00
|
|
|
let regexp = new RegExp(exports.FIND_HBS_REGEX)
|
|
|
|
let matches = string.match(regexp)
|
|
|
|
if (matches == null) {
|
|
|
|
return string
|
|
|
|
}
|
|
|
|
for (let match of matches) {
|
|
|
|
const idx = string.indexOf(match)
|
|
|
|
string = exports.swapStrings(string, idx, match.length, "Invalid Binding")
|
|
|
|
}
|
|
|
|
return string
|
|
|
|
}
|