Skip to content

miguelrk/object-replace-mustache

 
 

Repository files navigation

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 }

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.

About

'mustache.js' but for replacing object properties

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.4%
  • JavaScript 2.6%