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 3 years ago
  2. Django Collapsed Stacked Inlines by mkarajohn 5 years, 2 months ago
  3. Dynamically adding forms to a formset. OOP version. by halfnibble 10 years, 10 months ago
  4. Convert multiple select for m2m to multiple checkboxes in django admin form by abidibo 12 years, 11 months ago
  5. Django admin inline ordering - javascript only implementation by ojhilt 13 years, 3 months ago

Comments

Please login first before commenting.