Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andrienko/chit
A tiny JS template engine snippet
https://github.com/andrienko/chit
Last synced: 7 days ago
JSON representation
A tiny JS template engine snippet
- Host: GitHub
- URL: https://github.com/andrienko/chit
- Owner: andrienko
- Created: 2015-10-08T17:22:53.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-19T17:37:50.000Z (about 9 years ago)
- Last Synced: 2023-08-19T23:21:45.778Z (about 1 year ago)
- Language: JavaScript
- Size: 176 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Chit.js
===Chit.JS is a tiny js template engine based on [a post by John Resig](http://ejohn.org/blog/javascript-micro-templating/)
It is just a snippet.
Example
---Just add something like that to header:
<h1><%= title%></h1>
<ul>
<% for ( var i = 0; i < users.length; i++ ) { %>
<li>Hello, <a href="<%=users[i].url%>"><%=users[i].name%></a>!</li>
<% } %>
</ul>
Then call something like
var data = {
users:[
{name: 'John', url:'http://[email protected]'},
{name: 'Mary', url:'http://[email protected]'}
],
title:'User list:'
};chit.render('hello',data);
The template will then be cached and rendered. Render result will be returned/