UNPKG

liferay-theme-tasks

Version:

A set of tasks for building and deploying Liferay Portal themes.

28 lines (22 loc) 639 B
/** * SPDX-FileCopyrightText: © 2017 Liferay, Inc. <https://liferay.com> * SPDX-License-Identifier: MIT */ /** * "Normalize" an HTML template by adding JS-injection placeholders as * HTML comments at the end of the template <body>. * * @param {string} template * @return {string} */ function normalize(template) { const beforeRegex = /<\/body>/; const replacementContent = '<!-- inject:js -->\n<!-- endinject -->\n\n'; if (template.indexOf(replacementContent) === -1) { template = template.replace(beforeRegex, (match) => { return replacementContent + match; }); } return template; } module.exports = normalize;