My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Featured
Downloads

Jtl is a javascript template engine I ported from Django(http://www.djangoproject.com/)'s template engine

Introduction

Jtl is a javascript template engine

Usage

var t = new Jtl(
  '{%for people in namelist reversed%}'+
    '{{forloop.counter}}.{{people.name}}'+
    '{%if people.email%}(email:{{people.email}})>{%endif%}'+
    '{%for tid in people.topicID%}{{tid}}-{%endfor%}<br>'+
  '{%endfor%}');
var c = {
  namelist :[
    {name : 'John' , email : 'we_2002@163.com',topicID:[1,2,3,4]},
    {name : 'Nick' , email : 'we_2006@163.com',topicID:[4,3,6]},
    {name : 'Tony', topicID:[5,66,7]}
  ]
};
document.write(t.render(c));

which result in:

 1.Tony5-66-7-
 2.Nick(email:we_2006@163.com)>4-3-6-
 3.John(email:we_2002@163.com)>1-2-3-4-
Powered by Google Project Hosting