mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 17:12:43 +00:00
16 lines
422 B
JavaScript
16 lines
422 B
JavaScript
/**
|
|
* Render a template
|
|
* @template T
|
|
* @param template {T} The template to render (must be stringify-able)
|
|
* @param substitutions {[string, string][]} the substitutions
|
|
* @returns {T}
|
|
*/
|
|
export function renderTemplate(template, substitutions) {
|
|
return JSON.parse(
|
|
substitutions.reduce(
|
|
(template, [search, replace]) => template.replaceAll(search, replace),
|
|
JSON.stringify(template),
|
|
),
|
|
);
|
|
}
|