Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rbarilani/parse-template-object
Parse objects that use templates as values (like grunt config)
https://github.com/rbarilani/parse-template-object
Last synced: 21 days ago
JSON representation
Parse objects that use templates as values (like grunt config)
- Host: GitHub
- URL: https://github.com/rbarilani/parse-template-object
- Owner: rbarilani
- License: mit
- Created: 2016-04-25T12:50:55.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-12-11T14:35:22.000Z (about 7 years ago)
- Last Synced: 2024-11-09T07:31:54.710Z (3 months ago)
- Language: JavaScript
- Size: 17.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Parse Template Object
Parse objects that use templates as values (like grunt config).
It's actually based/derived on [grunt config mechanism](https://github.com/gruntjs/grunt).[![Build Status](https://travis-ci.org/rbarilani/parse-template-object.svg?branch=master)](https://travis-ci.org/rbarilani/parse-template-object)
### Install
```
npm install @rbarilani/parse-template-object --save
```### Usage
```javascript
//
// Basic usage
//
var parse = require('@rbarilani/parse-template-object');var object = {
meta: { version: '1.1.0' },
package: {
name: 'awesome-<%= meta.version %>'
},
arr: ['foo', '<%= package.name %>']
};console.log(parse(object));
// OUT:
//
// {
// meta: { version: '1.1.0' },
// package: {
// name: 'awesome-1.1.0'
// }
// arr: ['foo', 'awesome-1.1.0']
// }
// ------------------------------------//
// Add extra context with "imports" options
//
var object2 = {
package: {
name: 'awesome-<%= meta.version %>'
},
arr: ['foo', '<%= package.name %>']
};var parsed2 = parse(object2, {
imports: {
meta: { version: '1.1.0'}
}
});console.log(parsed2);
// OUT:
//
// {
// package: {
// name: 'awesome-1.1.0'
// }
// arr: ['foo', 'awesome-1.1.0']
// }
// ------------------------------------
```### LICENSE
Copyright 2017 Ruben Barilani
Project is released under the MIT license. See LICENSE for details.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License