pokap/notpl

无模板的快速模板引擎

维护者

详细信息

github.com/pokap/notpl

源代码

问题

安装: 13

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

公开问题: 0

语言:JavaScript

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

This package is not auto-updated.

Last update: 2024-09-22 03:17:26 UTC


README

无模板的快速模板引擎

## 快速开始

克隆仓库: git clone git://github.com/pokap/notpl.git.

用法

在你的html文件中

<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'}]
  ]);

});