Access utils methods via modules
Allows for monkey patching (under ES5 systems). This somewhat mirrors the proposed behavior in https://github.com/square/es6-module-transpiler/issues/37 but applies the behavior via manual code changes rather than compiler support.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
/*jshint eqnull: true */
|
||||
|
||||
import { extend, isEmpty } from "./utils";
|
||||
/*globals Exception, Utils */
|
||||
module Utils from "./Utils";
|
||||
import Exception from "./exception";
|
||||
|
||||
export var VERSION = "1.0.0";
|
||||
@@ -48,7 +47,7 @@ HandlebarsEnvironment.prototype = {
|
||||
registerHelper: function(name, fn, inverse) {
|
||||
if (toString.call(name) === objectType) {
|
||||
if (inverse || fn) { throw new Exception('Arg not supported with multiple helpers'); }
|
||||
extend(this.helpers, name);
|
||||
Utils.extend(this.helpers, name);
|
||||
} else {
|
||||
if (inverse) { fn.not = inverse; }
|
||||
this.helpers[name] = fn;
|
||||
@@ -57,7 +56,7 @@ HandlebarsEnvironment.prototype = {
|
||||
|
||||
registerPartial: function(name, str) {
|
||||
if (toString.call(name) === objectType) {
|
||||
extend(this.partials, name);
|
||||
Utils.extend(this.partials, name);
|
||||
} else {
|
||||
this.partials[name] = str;
|
||||
}
|
||||
@@ -148,7 +147,7 @@ function registerDefaultHelpers(instance) {
|
||||
instance.registerHelper('with', function(context, options) {
|
||||
if (isFunction(context)) { context = context.call(this); }
|
||||
|
||||
if (!isEmpty(context)) return options.fn(context);
|
||||
if (!Utils.isEmpty(context)) return options.fn(context);
|
||||
});
|
||||
|
||||
instance.registerHelper('log', function(context, options) {
|
||||
@@ -182,6 +181,6 @@ export function log(level, obj) { logger.log(level, obj); }
|
||||
|
||||
export var createFrame = function(object) {
|
||||
var obj = {};
|
||||
extend(obj, object);
|
||||
Utils.extend(obj, object);
|
||||
return obj;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*global Utils */
|
||||
module Utils from "./utils";
|
||||
import Exception from "./exception";
|
||||
import { escapeExpression, extend } from "./utils";
|
||||
import { COMPILER_REVISION, REVISION_CHANGES } from "./base";
|
||||
|
||||
function checkRevision(compilerInfo) {
|
||||
@@ -49,7 +50,7 @@ export function template(templateSpec, env) {
|
||||
|
||||
// Just add water
|
||||
var container = {
|
||||
escapeExpression: escapeExpression,
|
||||
escapeExpression: Utils.escapeExpression,
|
||||
invokePartial: invokePartialWrapper,
|
||||
programs: [],
|
||||
program: function(i, fn, data) {
|
||||
@@ -66,8 +67,8 @@ export function template(templateSpec, env) {
|
||||
|
||||
if (param && common && (param !== common)) {
|
||||
ret = {};
|
||||
extend(ret, common);
|
||||
extend(ret, param);
|
||||
Utils.extend(ret, common);
|
||||
Utils.extend(ret, param);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user