Skip to content

A small lib for injecting a JS object into a block of HTML without any data changes

Notifications You must be signed in to change notification settings

nosajio/micro-templating

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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">

About

A small lib for injecting a JS object into a block of HTML without any data changes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published