pokap/notpl

Fast template engine without template

Maintainers

Details

github.com/pokap/notpl

Source

Issues

Installs: 13

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Language:JavaScript

dev-master 2013-01-03 22:21 UTC

This package is not auto-updated.

Last update: 2024-04-21 00:38:02 UTC


README

Fast template engine without template

## Quick start

Clone the repo: git clone git://github.com/pokap/notpl.git.

Usage

In your html file :

<div id="container"></div>
// -------------
// controller

var $tbody = function (tbody) {
  $([["Mark", "Otto"], ["Jacob", "Thornton"]]).each(function (index, value) {
    tbody.noTpl([['tr', [
      ['td', (index + 1)],
      ['td', value[0]],
      ['td', value[1]]
    ]]]);
  });
};

// -------------
// template

$(function(){

  var container = $("#container");

  container.html("");
  container.noTpl([
    ['table', [
      ['thead', [
        ['tr', [
          ['th', '#'],
          ['th', 'First Name'],
          ['th', 'Last Name']
        ]
      ]]],
      ['tbody', $tbody]
    ], {"class": 'table table-striped'}],
    ['form', [
      ['fieldset', [
        ['input', null, {"type": 'text', "placeholder": 'Type something…'}],
        ['button', 'Submit', {"type": 'submit', "class": 'btn'}]
      ]]
    ], {"method": 'POST', "action": '#', 'class': 'form-inline'}]
  ]);

});