Client-side django template with jQuery

 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 Template "include_raw" tag by wwu.housing 3 years, 9 months ago
  2. Client-side Django-style date & time string formatting by robbie 6 years, 2 months ago
  3. Orderable inlines using drag and drop with jQuery UI by simon 4 years, 8 months ago
  4. Add special field lookups to the Admin list_filter display by whiteinge 5 years, 3 months ago
  5. jQuery slugify plugin by girasquid 4 years ago

Comments

(Forgotten your password?)