microtpl

1.0.3 • Public • Published

Micro Templating Lib

It can:

  • Insert strings into an element or as attributes.
  • Nested referencing, as in data-template-part="media.image.small".
  • Basic loops of arrays of objects.

Install

`npm install microtpl``

Insert something

<h1 data-template-part="title"></h1>

Loop over Array

JS

var data = {
  items: [
    {title: 'a title'},
    {title: 'another title'},
  ],
};
 
micro.inject($el, data);

HTML

<ul>
  <li data-repeat="items">
    <span data-template-part="title"></span>
  </li>
</ul>

Inject Attribute

<img src=""
     data-template-part="image.src"
     data-template-attr="src">

Readme

Keywords

none

Package Sidebar

Install

npm i microtpl

Weekly Downloads

2

Version

1.0.3

License

ISC

Last publish

Collaborators

  • nosaj