1.0.1 • Published 6 years ago

jquery-template-engine v1.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

jquery-template-egine

jQuery simple template engine with support for loops and conditional data

Installation

Import this JS in your HTML

<script src="https://cdn.jsdelivr.net/npm/jquery-template-engine@1.0.1"></script>

or install it via npm

npm i --save jquery-template-engine

Usage

In your HTML, use the data-te attributes for preparing the templates:

<h1 data-te-v="selection.country"></h1>
<p data-te-v="selection.city"></p>
<p>Other cities...</p>
<ul data-te-for="city of cities">
  <li data-te-v="city.name"></li>
</ul>

And then you can use:

$("body").templateEngine({
    selection : {
      country: 'Spain',
      city: 'Valencia'
    },
    cities : [
      {name : 'Barcelona'},
      {name : 'Madrid'},
      {name : 'Sevilla'},
      {name : 'Valencia'}
    ]
  })

Features