Break safe string out into standalone module

This commit is contained in:
kpdecker
2013-10-01 21:18:10 -05:00
parent 6a23391a9a
commit e75839b185
3 changed files with 16 additions and 12 deletions
+2 -1
View File
@@ -2,8 +2,9 @@ import { HandlebarsEnvironment, createFrame, logger, log } from "./handlebars/ba
// Each of these augment the Handlebars object. No need to setup here.
// (This is done to easily share code between commonjs and browse envs)
import SafeString from "./handlebars/safe-string";
import Exception from "./handlebars/exception";
import { SafeString, extend, escapeExpression, isEmpty } from "./handlebars/utils";
import { extend, escapeExpression, isEmpty } from "./handlebars/utils";
import { compile, precompile } from "./handlebars/compiler/compiler";
import { template } from "./handlebars/runtime";
+10
View File
@@ -0,0 +1,10 @@
// Build out our basic SafeString type
function SafeString(string) {
this.string = string;
}
SafeString.prototype.toString = function() {
return "" + this.string;
};
export default SafeString;
+4 -11
View File
@@ -1,15 +1,8 @@
import SafeString from "./safe-string";
var toString = Object.prototype.toString,
isArray = Array.isArray;
// Build out our basic SafeString type
export function SafeString(string) {
this.string = string;
};
SafeString.prototype.toString = function() {
return "" + this.string;
};
var escape = {
"&": "&",
"<": "&lt;",
@@ -22,9 +15,9 @@ var escape = {
var badChars = /[&<>"'`]/g;
var possible = /[&<>"'`]/;
var escapeChar = function(chr) {
function escapeChar(chr) {
return escape[chr] || "&amp;";
};
}
export function extend(obj, value) {
for(var key in value) {