Skip to content

tonekk/ICanHaz.load

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ICanHaz.load

License Bower version

Little extension for loading templates asynchronously with ICanHaz.js and jQuery

Usage

// Global config
ich.templatePath = '/assets/templates';
// optionally, set a special extension (.mustache is standard)
ich.templateExtension = 'tpl';

ich.load('template', function() {
  // Called when template has been loaded
  var content = ich.template({
    foo: 'bar'
  });
  
  $element.html(content);
});

Call ich.load as many times as you want, the template will be only requested once.

But wait, there is an even shorter method:

ich.loadTemplate('template', { foo: 'bar' }, function($content) {
  $element.html($content);
});

Installation

Just load ICanHaz.load.js somewhere after ICanHaz.js and jQuery and you're good to go.

Testing

Tests are written using jasmine and can be executed in the browser, by browsing test/index.html. This project is too tiny for continuous integration imo.

About

Little extension for loading views with ICanHaz.js. Requires jQuery

Resources

License

Stars

Watchers

Forks

Packages

No packages published