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?
已存档?
是复刻?
已锁定?
是镜像?
是私有?