@ea-lab/reactive-json
Version:
A REACT-based lib that transforms JSON (or YAML) into interactive HTML markup.
22 lines (21 loc) • 585 B
JavaScript
import { evaluateTemplateValue as l } from "../TemplateSystem.js";
const r = (e, ...t) => t.length ? r(e = e.replace(r.token || "$token", t.shift()), ...t) : e, u = ({ templateContexts: e }, t, ...a) => {
const n = a.map((o) => l({
globalDataContext: e.globalDataContext,
templateContext: e.templateContext,
valueToEvaluate: o
}));
return r(t, ...n);
}, p = (e, t) => {
if (typeof t == "string")
return t;
if (Array.isArray(t)) {
const [a, ...n] = t;
return u(e, a, ...n);
}
return "";
};
export {
u as formatString,
p as maybeFormatString
};