jTemplate is a front-end JavaScript based template engine.

Allows creating complex themes that are rendered completely on the user's end. Fetching raw data via Ajax and rendering it becomes a trivial task.

jTemplate API and examples: http://jtemplates.tpython.com/

How does it work with drupal?

Front-end (javascript invocation)

Drupal.theme('jTemplate', '[callback]'); //will fetch callback theme from server via ajax and cache it
Drupal.theme('jTemplate', '[callback]', '#theme-container-parent'); //will (fetch and cache theme if not done so) execute theme on #theme-container-parent
/*
will (fetch and cache theme if not done so) execute theme on #theme-container-parent with {param:data} arguments.
*/
Drupal.theme('jTemplate', '[callback]', '#theme-container-parent', {param:data});

Back-end (php preparation):

/**
* Create hook_jtemplate_themes();
*/
function mymodule_jtemplate_themes() {
  return array (
    'mymodule_theme' => array(
     'template' => '{#for index = 1 to $T.limit} {$T.index} {#/for}',
     'settings'  => array(),
     'includes'  => array(),
    ),
  );
}

Create a module 'mymodule', in it define hook_jtemplate_themes(). then to call your mymodule_theme template execute this:
Drupal.theme('jTemplate', 'mymodule_theme', '[#theme-container-parent]', {limit:5});

Expected output:
1 2 3 4 5

Project Information

Downloads