T.js
A tiny javascript templating framework in ~400 bytes gzipped
Install / Use
/learn @jasonmoo/T.jsREADME
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
Related Skills
node-connect
341.6kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
341.6kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.6kCommit, push, and open a PR
