Added the new safestring type and a test for its implementation.

This commit is contained in:
Alan Johnson
2010-08-08 17:56:35 -04:00
parent d5d06c71f0
commit 792251f6c9
2 changed files with 13 additions and 0 deletions
+7
View File
@@ -112,6 +112,13 @@ Handlebars.ParseError = function(message) {
this.message = message;
};
// Build out our basic SafeString type
Handlebars.SafeString = function(string) {
this.string = string;
}
Handlebars.SafeString.prototype.toString = function() {
return this.string.toString();
}
Handlebars.helperMissing = function(object, fn) {
var ret = "";
+6
View File
@@ -175,4 +175,10 @@ test("the fallback hash is available is nested contexts", function() {
module("partials");
module("safestring");
test("constructing a safestring from a string and checking its type", function() {
var safe = new Handlebars.SafeString("testing 1, 2, 3");
ok(safe instanceof Handlebars.SafeString, "SafeString is an instance of Handlebars.SafeString");
equal(safe, "testing 1, 2, 3", "SafeString is equivalent to its underlying string");
});