summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/runtime.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/handlebars/runtime.js')
-rw-r--r--lib/handlebars/runtime.js35
1 files changed, 16 insertions, 19 deletions
diff --git a/lib/handlebars/runtime.js b/lib/handlebars/runtime.js
index f1839aa..874728f 100644
--- a/lib/handlebars/runtime.js
+++ b/lib/handlebars/runtime.js
@@ -3,13 +3,13 @@ import Exception from './exception';
import { COMPILER_REVISION, REVISION_CHANGES, createFrame } from './base';
export function checkRevision(compilerInfo) {
- var compilerRevision = compilerInfo && compilerInfo[0] || 1,
- currentRevision = COMPILER_REVISION;
+ const compilerRevision = compilerInfo && compilerInfo[0] || 1,
+ currentRevision = COMPILER_REVISION;
if (compilerRevision !== currentRevision) {
if (compilerRevision < currentRevision) {
- var runtimeVersions = REVISION_CHANGES[currentRevision],
- compilerVersions = REVISION_CHANGES[compilerRevision];
+ const runtimeVersions = REVISION_CHANGES[currentRevision],
+ compilerVersions = REVISION_CHANGES[compilerRevision];
throw new Exception('Template was precompiled with an older version of Handlebars than the current runtime. ' +
'Please update your precompiler to a newer version (' + runtimeVersions + ') or downgrade your runtime to an older version (' + compilerVersions + ').');
} else {
@@ -41,7 +41,7 @@ export function template(templateSpec, env) {
}
partial = env.VM.resolvePartial.call(this, partial, context, options);
- var result = env.VM.invokePartial.call(this, partial, context, options);
+ let result = env.VM.invokePartial.call(this, partial, context, options);
if (result == null && env.compile) {
options.partials[options.name] = env.compile(partial, templateSpec.compilerOptions, env);
@@ -49,8 +49,8 @@ export function template(templateSpec, env) {
}
if (result != null) {
if (options.indent) {
- var lines = result.split('\n');
- for (var i = 0, l = lines.length; i < l; i++) {
+ let lines = result.split('\n');
+ for (let i = 0, l = lines.length; i < l; i++) {
if (!lines[i] && i + 1 === l) {
break;
}
@@ -66,7 +66,7 @@ export function template(templateSpec, env) {
}
// Just add water
- var container = {
+ let container = {
strict: function(obj, name) {
if (!(name in obj)) {
throw new Exception('"' + name + '" not defined in ' + obj);
@@ -74,8 +74,8 @@ export function template(templateSpec, env) {
return obj[name];
},
lookup: function(depths, name) {
- var len = depths.length;
- for (var i = 0; i < len; i++) {
+ const len = depths.length;
+ for (let i = 0; i < len; i++) {
if (depths[i] && depths[i][name] != null) {
return depths[i][name];
}
@@ -94,7 +94,7 @@ export function template(templateSpec, env) {
programs: [],
program: function(i, data, declaredBlockParams, blockParams, depths) {
- var programWrapper = this.programs[i],
+ let programWrapper = this.programs[i],
fn = this.fn(i);
if (data || depths || blockParams || declaredBlockParams) {
programWrapper = wrapProgram(this, i, fn, data, declaredBlockParams, blockParams, depths);
@@ -111,7 +111,7 @@ export function template(templateSpec, env) {
return value;
},
merge: function(param, common) {
- var obj = param || common;
+ let obj = param || common;
if (param && common && (param !== common)) {
obj = Utils.extend({}, common, param);
@@ -124,15 +124,14 @@ export function template(templateSpec, env) {
compilerInfo: templateSpec.compiler
};
- function ret(context, options) {
- options = options || {};
- var data = options.data;
+ function ret(context, options = {}) {
+ let data = options.data;
ret._setup(options);
if (!options.partial && templateSpec.useData) {
data = initData(context, data);
}
- var depths,
+ let depths,
blockParams = templateSpec.useBlockParams ? [] : undefined;
if (templateSpec.useDepths) {
depths = options.depths ? [context].concat(options.depths) : [context];
@@ -169,9 +168,7 @@ export function template(templateSpec, env) {
}
export function wrapProgram(container, i, fn, data, declaredBlockParams, blockParams, depths) {
- function prog(context, options) {
- options = options || {};
-
+ function prog(context, options = {}) {
return fn.call(container,
context,
container.helpers, container.partials,