This project uses the concepts of mustache for objects. Properties with {{ stringsWithCurlyBrackets }}
placeholders get replaced by their corresponding view object properties. It's pretty useful for storing 'dynamic' objects in databases.
npm i object-replace-mustache
import { replace } from "object-replace-mustache";
const original = { isTest: "{{ nested.test }}" };
const view = { nested: { test: true } };
const transformed = replace(original, view);
console.log(transformed);
// { isTest: true }
There is also a render
function that is like mustache.js or handlebars
import { render } from "object-replace-mustache";
const rendered = render("hello { test }!", { test: "world" });
console.log(rendered);
// hello world!
Simply run npm test
and all your tests in the test/
directory will be run. It has full support for Visual Studio Code. You can use the debugger to set breakpoints.
Licensed under the MIT license.