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 2 years, 9 months ago
  2. Client-side Django-style date & time string formatting by robbie 5 years, 2 months ago
  3. Allow editing of the selected object of the filter_vertical/filter_horizontal widget with jquery by jpic 3 years, 7 months ago
  4. JSON-compatible query filter specification by mhalle 4 years, 1 month ago
  5. jQuery Autocomplete by zeeg 4 years, 11 months ago

Comments

(Forgotten your password?)