Skip to content

thatcher/jquery-tmpl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A jQuery templating plugin - created for demonstration purposes.

$("#sometmpl1")
    .render( dataObject ) // Returns a LI with all the data filled in
    .appendTo("ul");

$("#sometmpl1")
    .render( arrayOfDataObjects ) // Returns multiple LIs with data filled in
    .appendTo("ul");

$("#sometmpl2")
    .render( arrayOfDataObjects ) // Returns multiple LIs with data filled in
    .appendTo("ul");
        

// Appends one LI, filled with data, into the UL
$("ul").append( tmpl, dataObject );

// Appends multiple LI, filled with data, into the UL
$("ul").append( tmpl, arrayOfDataObjects );


$("#sometmpl3")
    .render( dataObject ) // Returns a LI with all the data filled in
    .appendTo("ul");
    
   
// renders asyncronously via remote templates (still cached)
$.render({
    url: 'examples/templates/remote1.html',
    templateData: dataObject, 
    success: function(rendered){
        $('ul').append(rendered);
    }
});

// renders syncronously via remote templates (still cached)
$('ul').append( $.render({
    async:false,
    url: 'examples/templates/remote2.html',
    templateData: dataObject
}) );

$("#sometmpl4")
    .render( dataObject ) // Returns a LI with all the data filled in
    .appendTo("ul");

Compiling templates with Envjs

> ./bin/manage.sh compile-templates /path/to/jquery-tmpl/examples/comment.html /path/to/generated/tmpl.examples.comment.js

About

A templating plugin for jQuery.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.9%
  • Shell 0.1%