Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/loicmahieu/traverse-template
Traverse object for templating values
https://github.com/loicmahieu/traverse-template
Last synced: about 1 month ago
JSON representation
Traverse object for templating values
- Host: GitHub
- URL: https://github.com/loicmahieu/traverse-template
- Owner: LoicMahieu
- License: mit
- Created: 2016-07-07T16:23:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-24T12:02:50.000Z (almost 8 years ago)
- Last Synced: 2024-11-10T03:44:05.946Z (2 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
traverse-template
============[![Build Status](http://img.shields.io/travis/LoicMahieu/traverse-template.svg?style=flat-square)](https://travis-ci.org/LoicMahieu/traverse-template)
[![npm version](https://img.shields.io/npm/v/traverse-template.svg?style=flat-square)](http://badge.fury.io/js/traverse-template)
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://raw.githubusercontent.com/LoicMahieu/traverse-template/master/LICENSE)Traverse object for templating values
## Install
### npm
```
$ npm install traverse-template
```## Usage
### Basic
```javascript
var obj = traverseTemplate({
greeting: 'Hello',
hello_tony: '${greeting} Tony'
})// Will output
{
greeting: 'Hello',
hello_tony: 'Hello Tony'
}
```### With given locals
```javascript
var obj = traverseTemplate({
hello_tony: '${greeting} Tony'
}, {
greeting: 'Hello'
})// Will output
{
bar: 'Hello Tony'
}
```### Nested support
```javascript
var obj = traverseTemplate({
greets: [
'${greeting} Tony',
'${greeting} Boy'
],
foo: {
bar: '${greeting}'
}
}, {
greeting: 'Hello'
})// Will output
{
greets: [
'Hello Tony',
'Hello Body'
],
foo: {
bar: 'Hello'
}
}
```## License
Released under the [MIT Licence](https://raw.githubusercontent.com/LoicMahieu/traverse-template/master/LICENSE)## Author
[Loïc Mahieu](https://github.com/LoicMahieu/)