Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #4 from nponeccop/patch-3

Improve deferred implementation, support nested templates
  • Loading branch information...
commit cea03fdee1117245ddfb7b9b1cd872604b0885c1 2 parents 379594b + a886fca
@markdalgleish authored
Showing with 3 additions and 4 deletions.
  1. +3 −4 tmpload-v1.0.js
View
7 tmpload-v1.0.js
@@ -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);
});
Please sign in to comment.
Something went wrong with that request. Please try again.