Popularity
2.9
Declining
Activity
0.0
Stable
793
73
87

Description

For more advanced usage check the t_test.html.

This software is released under the MIT license.

Programming language: HTML
Tags: Templating Engines    

t.js alternatives and similar libraries

Based on the "Templating Engines" category

Do you think we are missing an alternative of t.js or a related project?

Add another 'Templating Engines' Library

README

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


*Note that all licence references and agreements mentioned in the t.js README section above are relevant to that project's source code only.