npm.io
1.0.2 • Published 8 years ago

@brook/strbuf

Licence
MIT
Version
1.0.2
Deps
0
Size
5 kB
Vulns
0
Weekly
0

strbuf

Build Status Code Climate

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

Keywords