Permalink
Browse files

Merge pull request #4 from nponeccop/patch-3

Improve deferred implementation, support nested templates
  • Loading branch information...
markdalgleish committed Aug 15, 2011
2 parents 379594b + a886fca commit cea03fdee1117245ddfb7b9b1cd872604b0885c1
Showing with 3 additions and 4 deletions.
  1. +3 −4 tmpload-v1.0.js
View
@@ -8,7 +8,7 @@ github.com/markdalgleish/tmpload/blob/master/MIT-LICENSE.txt
(function($, undefined) {
//Template cache
var templates = {};
-
+
$.tmpload = function(obj, url) {
if (url === undefined) {
//Declaring template(s)
@@ -27,10 +27,9 @@ github.com/markdalgleish/tmpload/blob/master/MIT-LICENSE.txt
else if (typeof obj === "string") {
if (typeof templates[obj] === "string") {
//The template hasn't been loaded yet
- return $.Deferred(function(dfd) {
+ return templates[obj] = $.Deferred(function(dfd) {
$.get(templates[obj]).success(function(d) {
- templates[obj] = $.template(d);
- dfd.resolve(templates[obj]);
+ dfd.resolve($.template(obj, d));
}).error(function(d) {
dfd.reject(d);
});

0 comments on commit cea03fd

Please sign in to comment.