@redocly/theme
Version:
Shared UI components lib
15 lines • 648 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.replaceInputsWithValue = replaceInputsWithValue;
function replaceInputsWithValue(node, inputs) {
const validKeys = Object.entries(inputs)
.filter(([_, input]) => input.value)
.map(([key]) => key)
.join('|');
if (!validKeys) {
return node;
}
const inputRegex = new RegExp(`\\{\\{\\s*(${validKeys})\\s*\\}\\}`, 'g');
return node.replace(inputRegex, (_, inputKey) => { var _a; return (_a = inputs[inputKey]) === null || _a === void 0 ? void 0 : _a.value; });
}
//# sourceMappingURL=replace-inputs-with-value.js.map