t.js

A tiny javascript templating framework in ~400 bytes gzipped

  • 所有者: jasonmoo/t.js
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

t.js

A tiny javascript templating framework in ~400 bytes gzipped

t.js is a simple solution to interpolating values in an html string for insertion into the DOM via innerHTML.

Features

  • Simple interpolation: {{=value}}
  • Scrubbed interpolation: {{%unsafe_value}}
  • Name-spaced variables: {{=User.address.city}}
  • If/else blocks: {{value}} <<markup>> {{:value}} <<alternate markup>> {{/value}}
  • If not blocks: {{!value}} <<markup>> {{/!value}}
  • Object/Array iteration: {{@object_value}} {{=_key}}:{{=_val}} {{/@object_value}}
  • Multi-line templates (no removal of newlines required to render)
  • Render the same template multiple times with different data
  • Works in all modern browsers

How to use

var template = new t("<div>Hello {{=name}}</div>");
document.body.innerHtml = template.render({name: "World!"});

For more advanced usage check the t_test.html.

This software is released under the MIT license.


Coffeescript version maintained by @davidrekow

PHP version maintained by @ramon82

主要指標

概覽
名稱與所有者jasonmoo/t.js
主編程語言HTML
編程語言JavaScript (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2012-08-13 22:52:45
推送於2023-10-18 16:24:46
最后一次提交2015-11-06 08:09:37
發布數0
用户参与
星數831
關注者數70
派生數86
提交數13
已啟用問題?
問題數11
打開的問題數6
拉請求數2
打開的拉請求數7
關閉的拉請求數5
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?