@brook/strbuf
v1.0.2
Published
concat javascript string in es6 way
Downloads
3
Readme
strbuf
Concat javascript string in es6 way, and more!
Usage
Given:
var json = {
msg: "foo",
info: { bar: 'hello'},
list: [
{ name: 'a', date: '2016/7'},
{ name: 'b', date: '2016/8'},
]
};
Expect:
Using as a function
strbuf('hello, ${msg}, ${info.bar}', json);
strbuf('hello, {0}, {1}', 'foo', 'hello');
Using as a class
var html = new strbuf('<ul>');
html.push('<li>${msg}-${info.bar}</li>', json)
.push('<li>{0}-{1}</li>', 'foo', 'hello');
html.pushArray('<li>${name} - ${date}</li>', json.list);
html.toString();
License
MIT