diff options
Diffstat (limited to 'lib/handlebars')
-rw-r--r-- | lib/handlebars/base.js | 20 | ||||
-rw-r--r-- | lib/handlebars/utils.js | 22 |
2 files changed, 23 insertions, 19 deletions
diff --git a/lib/handlebars/base.js b/lib/handlebars/base.js index f9d8aa9..9a1bf3e 100644 --- a/lib/handlebars/base.js +++ b/lib/handlebars/base.js @@ -12,25 +12,11 @@ export var REVISION_CHANGES = { 4: '>= 1.0.0' }; -var toString = Object.prototype.toString, +var isArray = Utils.isArray, + isFunction = Utils.isFunction, + toString = Utils.toString, objectType = '[object Object]'; -// Sourced from lodash -// https://github.com/bestiejs/lodash/blob/master/LICENSE.txt -var isFunction = function(value) { - return typeof value === 'function'; -}; -// fallback for older versions of Chrome and Safari -if (isFunction(/x/)) { - isFunction = function(value) { - return typeof value === 'function' && toString.call(value) === '[object Function]'; - }; -} - -function isArray(value) { - return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false; -} - export function HandlebarsEnvironment(helpers, partials) { this.helpers = helpers || {}; this.partials = partials || {}; diff --git a/lib/handlebars/utils.js b/lib/handlebars/utils.js index 998c9ca..65e91f9 100644 --- a/lib/handlebars/utils.js +++ b/lib/handlebars/utils.js @@ -1,7 +1,5 @@ import SafeString from "./safe-string"; -var isArray = Array.isArray; - var escape = { "&": "&", "<": "<", @@ -26,6 +24,26 @@ export function extend(obj, value) { } } +export var toString = Object.prototype.toString; + +// Sourced from lodash +// https://github.com/bestiejs/lodash/blob/master/LICENSE.txt +var isFunction = function(value) { + return typeof value === 'function'; +}; +// fallback for older versions of Chrome and Safari +if (isFunction(/x/)) { + isFunction = function(value) { + return typeof value === 'function' && toString.call(value) === '[object Function]'; + }; +} +export var isFunction; + +export var isArray = Array.isArray || function(value) { + return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false; +}; + + export function escapeExpression(string) { // don't escape SafeStrings, since they're already safe if (string instanceof SafeString) { |