some minor refactorings
This commit is contained in:
+2
-5
@@ -9,10 +9,9 @@ import Visitor from './handlebars/compiler/visitor';
|
||||
|
||||
import noConflict from './handlebars/no-conflict';
|
||||
|
||||
let _create = runtime.create;
|
||||
function create() {
|
||||
let hb = _create();
|
||||
|
||||
let hb = runtime.create();
|
||||
hb.create = create;
|
||||
hb.compile = function(input, options) {
|
||||
return compile(input, options, hb);
|
||||
};
|
||||
@@ -31,8 +30,6 @@ function create() {
|
||||
}
|
||||
|
||||
let inst = create();
|
||||
inst.create = create;
|
||||
|
||||
noConflict(inst);
|
||||
|
||||
inst.Visitor = Visitor;
|
||||
|
||||
@@ -4,21 +4,43 @@ import * as base from './handlebars/base';
|
||||
// (This is done to easily share code between commonjs and browse envs)
|
||||
import SafeString from './handlebars/safe-string';
|
||||
import Exception from './handlebars/exception';
|
||||
import * as Utils from './handlebars/utils';
|
||||
import {
|
||||
extend,
|
||||
toString,
|
||||
isFunction,
|
||||
isArray,
|
||||
indexOf,
|
||||
escapeExpression,
|
||||
isEmpty,
|
||||
createFrame,
|
||||
blockParams,
|
||||
appendContextPath
|
||||
} from './handlebars/utils';
|
||||
import {checkRevision, template, wrapProgram, resolvePartial, invokePartial, noop} from './handlebars/runtime';
|
||||
|
||||
import noConflict from './handlebars/no-conflict';
|
||||
|
||||
// For compatibility and usage outside of module systems, make the Handlebars object a namespace
|
||||
function create() {
|
||||
export function create() {
|
||||
let hb = new base.HandlebarsEnvironment();
|
||||
|
||||
Utils.extend(hb, base);
|
||||
extend(hb, base);
|
||||
hb.SafeString = SafeString;
|
||||
hb.Exception = Exception;
|
||||
hb.Utils = Utils;
|
||||
hb.escapeExpression = Utils.escapeExpression;
|
||||
|
||||
hb.Utils = {
|
||||
extend,
|
||||
toString,
|
||||
isFunction,
|
||||
isArray,
|
||||
indexOf,
|
||||
escapeExpression,
|
||||
isEmpty,
|
||||
createFrame,
|
||||
blockParams,
|
||||
appendContextPath
|
||||
};
|
||||
hb.escapeExpression = escapeExpression;
|
||||
hb.create = create;
|
||||
hb.VM = {checkRevision, template, wrapProgram, resolvePartial, invokePartial, noop};
|
||||
hb.template = function(spec) {
|
||||
return template(spec, hb);
|
||||
@@ -28,7 +50,6 @@ function create() {
|
||||
}
|
||||
|
||||
let inst = create();
|
||||
inst.create = create;
|
||||
|
||||
noConflict(inst);
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ export function indexOf(array, value) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
export function escapeExpression(string) {
|
||||
if (typeof string !== 'string') {
|
||||
// don't escape SafeStrings, since they're already safe
|
||||
@@ -88,6 +89,7 @@ export function escapeExpression(string) {
|
||||
return string.replace(badChars, escapeChar);
|
||||
}
|
||||
|
||||
|
||||
export function isEmpty(value) {
|
||||
if (!value && value !== 0) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user