Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Exposed predefines as well as fixed bug that prevented defaults from …

…cascading.
  • Loading branch information...
commit f219526415f4268437fdcc7a780fa11d13384709 1 parent c82623a
@xavi- authored
Showing with 8 additions and 3 deletions.
  1. +5 −2 index.js
  2. +1 −1  package.json
  3. +2 −0  test/test2.js
View
7 index.js
@@ -93,7 +93,6 @@
var match = /(.+?)\[(.+?)\]/.exec(key);
val = transforms[match[1]](match[2]);
}
- if(val == undefined) { callback(defVal); return; }
if(toString.call(val) === "[object Number]") { callback(val.toString()); return; }
@@ -108,6 +107,8 @@
}
defVal = levelUp(defVal);
+ if(val == undefined) { bind.to(defVal, {}, callback); return; }
+
if(toString.call(val) === "[object Boolean]") {
if(val) { bind.to(defVal, context, callback); } else { callback(""); }
return;
@@ -189,8 +190,9 @@
},
"file^": function unboundFile(callback, path, context) {
retrieveFile(path, function(data) { callback(data, context, true); });
- }
+ }
};
+ predefines["file-unescape"] = predefines["file^"];
var transforms = {
"if": function(key) {
@@ -250,4 +252,5 @@
};
bind.toFile = toFile;
bind.to = to;
+ bind.predefines = predefines;
}) (typeof exports === "object" ? exports : (window.bind = {}));
View
2  package.json
@@ -1,5 +1,5 @@
{ "name": "bind"
-, "version": "0.1.4"
+, "version": "0.1.5"
, "description": "A simple templating engine that smiles back"
, "keywords": [ "template", "engine", "bind" ]
, "maintainers":
View
2  test/test2.js
@@ -208,6 +208,8 @@ bind.to (
function (result) { assert.strictEqual (result, 'error message -- No Error --'); }
);
+bind.to("(: aaa ~ [: bbb ~ {: ccc ~ |: ddd ~ def :| :} :] :)", {}, function(data) { assert.equal(data, "def"); });
+
/*
### Embed files:
####The Markup:
Please sign in to comment.
Something went wrong with that request. Please try again.