https://github.com/codeofnode/templist
The templating specialist
https://github.com/codeofnode/templist
function json nested string template templist
Last synced: 11 months ago
JSON representation
The templating specialist
- Host: GitHub
- URL: https://github.com/codeofnode/templist
- Owner: codeofnode
- License: mit
- Created: 2017-07-15T19:59:53.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-02T06:37:50.000Z (about 8 years ago)
- Last Synced: 2024-04-27T14:46:07.266Z (almost 2 years ago)
- Topics: function, json, nested, string, template, templist
- Language: JavaScript
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# The Templist
> The templating specialist
## Install
```
$ npm install templist
```
## Usage
```js
const templist = require('templist');
const myoutput = templist( AnyStringOrPOJO,
{ variable : 'map' },
{ OptionalMethods: function(inp){ return modify(inp) } });
```
## What it can do
```txt
templist('hello {{whois}}', { whois : "john" }) --> 'hello john'
templist('hello {{whois.firstname}}', { whois : { firstname: "john" } }) --> 'hello john'
templist({ hello : "{{whois.firstname}}" }, { whois : { firstname: "john" } }) --> { hello : "john" }
templist({ "{{greet}}" : "{{whois.firstname}}" }, { greet : "hello", whois : { firstname: "john" } })
--> { hello : "john" }
templist({ "{{greet}}" : "{{whois}}" }, { greet : "hello", whois : { firstname: 'john' } })
--> { hello : { firstname: 'john' } }
templist({ "{{greet}}" : { @ : 'getName' } }, { greet : "hello" }, { getName : function(){ return 'john' } })
--> { hello : 'john' }
//via calls () fashion
templist({"gb{{1}}{{bm}}{{func(1,{{0}})}}":{"@":"func","params":true}},[3,9], {func:function(a,b){ return a+b; }})
---> {'gb9{{bm}}4': '3,9[object Object]'}
```
## Want more example?
> See [test file](https://github.com/codeofnode/templist/blob/master/test.js).
## License
Templist is released under the MIT license:
http://www.opensource.org/licenses/MIT