Login

Client-side django template with jQuery

Author:
ksjun
Posted:
July 5, 2008
Language:
JavaScript
Version:
Not specified
Score:
2 (after 2 ratings)

with jQuery and jQuery templates you can use the django template language on the client-side with javascript.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
$.extend($.template.regx, {django: /\{\{\s*([\w-]+)(?:\|([\w\.]*)(?:\:(.*?)?[\s\}])?)?\s*\}\}/g});
$.template.regx.standard = $.template.regx.django;

// test code
var template = $.template("<div>hello {{ name|substr:0,10 }}!!!</div>");
$(selector).append(template, {
    name: 'abcdefghijkl'
});

// or
var html = template.apply( {
    name: 'abcdefghijkl'
});

More like this

  1. Django Collapsed Stacked Inlines by applecat 1 year, 4 months ago
  2. Django Collapsed Stacked Inlines by mkarajohn 3 years, 5 months ago
  3. Dynamically adding forms to a formset. OOP version. by halfnibble 9 years, 1 month ago
  4. Convert multiple select for m2m to multiple checkboxes in django admin form by abidibo 11 years, 2 months ago
  5. Django admin inline ordering - javascript only implementation by ojhilt 11 years, 6 months ago

Comments

Please login first before commenting.