@brook/strbuf

concat javascript string in es6 way

Usage no npm install needed!

<script type="module">
  import brookStrbuf from 'https://cdn.skypack.dev/@brook/strbuf';
</script>

README

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