The templating specialist
$ npm install templist
const templist = require('templist');
const myoutput = templist( AnyStringOrPOJO,
{ variable : 'map' },
{ OptionalMethods: function(inp){ return modify(inp) } });
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]'}
See test file.
Templist is released under the MIT license: