Design Pattern for Reusable Apps: Getting into Details

Source article: Design Pattern for Reusable Apps: Getting into Details This article is an attempt to explain a technique for creating reusable and overridable apps that were partly mentioned in my last post. First of all, let’s remember the presentation by James Bennett about reusable apps from DjangoCon 2008: Also the upgraded version Real World […]

Django like templates in Javascript

Source article: Django like templates in Javascript Here’s a quick ‘n’ dirty Javascript function I hacked together that provides Django-like template substitution. function sformat(template, data) { return template.replace(/{{(.*?)}}/g, function(m, n) { return eval(‘data.’+n); }); } Used something like this: sformat(“Hello, {{ name }}!”, {name:”World”}); Which returns the following string: Hello, World! Alas, it doesn’t support […]

Django like templates in Javascript

Source article: Django like templates in Javascript Here’s a quick ‘n’ dirty Javascript function I hacked together that provides Django-like template substitution. function sformat(template, data) { return template.replace(/{{(.*?)}}/g, function(m, n) { return eval('data.'+n); }); } Used something like this: sformat("Hello, {{ name }}!", {name:"World"}); Which returns the following string: Hello, World! Alas, it doesn’t support […]

Django like templates in Javascript

Source article: Django like templates in Javascript Here’s a quick ‘n’ dirty Javascript function I hacked together that provides Django-like template substitution. function sformat(template, data) { return template.replace(/{{(.*?)}}/g, function(m, n) { return eval('data.'+n); }); } Used something like this: sformat("Hello, {{ name }}!", {name:"World"}); Which returns the following string: Hello, World! Alas, it doesn’t support […]