Break safe string out into standalone module
This commit is contained in:
+2
-1
@@ -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";
|
||||
|
||||
|
||||
@@ -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
@@ -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 = {
|
||||
"&": "&",
|
||||
"<": "<",
|
||||
@@ -22,9 +15,9 @@ var escape = {
|
||||
var badChars = /[&<>"'`]/g;
|
||||
var possible = /[&<>"'`]/;
|
||||
|
||||
var escapeChar = function(chr) {
|
||||
function escapeChar(chr) {
|
||||
return escape[chr] || "&";
|
||||
};
|
||||
}
|
||||
|
||||
export function extend(obj, value) {
|
||||
for(var key in value) {
|
||||
|
||||
Reference in New Issue
Block a user