Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This project is not covered by Drupal’s security advisory policy.
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
- Module categories: Content Display, Developer Tools
- 1 site reports using this module
- Created by litwol on , updated
- This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.