3.0.1 • Published 6 months ago

object-replace-mustache v3.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

object-replace-mustache

npm GitHub Workflow Status Code Climate maintainability Code Climate coverage libraries.io npm GitHub license

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.

Installation

npm i object-replace-mustache

Usage

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 }

render

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!

Testing

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.

License

Licensed under the MIT license.

3.0.1

6 months ago

3.0.0

6 months ago

2.4.1

6 months ago

2.4.0

6 months ago

2.3.1

8 months ago

2.3.0

1 year ago

2.2.0

1 year ago

2.1.0

1 year ago

2.0.0

1 year ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.1.0

4 years ago