jquery-template-engine

1.0.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i jquery-template-engine

Weekly Downloads

0

Version

1.0.1

License

ISC

Last publish

Collaborators

  • bommox