diff options
Diffstat (limited to 'config/webpack/loader/to-string-loader.js')
| -rw-r--r-- | config/webpack/loader/to-string-loader.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/config/webpack/loader/to-string-loader.js b/config/webpack/loader/to-string-loader.js index 248574a..025ea5e 100644 --- a/config/webpack/loader/to-string-loader.js +++ b/config/webpack/loader/to-string-loader.js @@ -1,7 +1,17 @@ +/** + * Webpack loader that converts HTML template files into JavaScript modules. + * It escapes template literals and replaces `$name$` placeholders with + * `${name}` interpolation syntax so the exported function can accept a + * replacements object. + * + * @param {string} source - Raw HTML file content. + * @returns {string} A JS module that exports a function accepting + * replacement values and returning the interpolated HTML string. + */ export default function(source) { source = source .replaceAll("\\", "\\\\") - .replaceAll("`","\\`") + .replaceAll("`", "\\`") .replaceAll("${", "\\${"); const replacements = {}; |
