/
githubmirror
/
strapi
Обзор
Документация
Войти
/
githubmirror
/
strapi
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/core/utils/src/template.ts
18 строк
825 B
Alexandre Bodin
Init utils in ts
28 апр 2023, 09:25
28 апр 2023, 09:25
fe33b88
Код
Авторство
О чём код?
/** * Create a strict interpolation RegExp based on the given variables' name */ const createStrictInterpolationRegExp = (allowedVariableNames: string[], flags: string) => { const oneOfVariables = allowedVariableNames.join('|'); // 1. We need to match the delimiters: <%= ... %> // 2. We accept any number of whitespaces characters before and/or after the variable name: \s* ... \s* // 3. We only accept values from the variable list as interpolation variables' name: : (${oneOfVariables}) return new RegExp(`<%=\\s*(${oneOfVariables})\\s*%>`, flags); }; /** * Create a loose interpolation RegExp to match as many groups as possible */ const createLooseInterpolationRegExp = (flags: string) => new RegExp(/<%=([\s\S]+?)%>/, flags); export { createStrictInterpolationRegExp, createLooseInterpolationRegExp };