Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

component-builder-handlebars

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

component-builder-handlebars - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

601

example/build/build.js

@@ -23,2 +23,85 @@ /**

/**
* Meta info, accessible in the global scope unless you use AMD option.
*/
require.loader = 'component';
/**
* Internal helper object, contains a sorting function for semantiv versioning
*/
require.helper = {};
require.helper.semVerSort = function(a, b) {
var aArray = a.version.split('.');
var bArray = b.version.split('.');
for (var i=0; i<aArray.length; ++i) {
var aInt = parseInt(aArray[i], 10);
var bInt = parseInt(bArray[i], 10);
if (aInt === bInt) {
var aLex = aArray[i].substr((""+aInt).length);
var bLex = bArray[i].substr((""+bInt).length);
if (aLex === '' && bLex !== '') return 1;
if (aLex !== '' && bLex === '') return -1;
if (aLex !== '' && bLex !== '') return aLex > bLex ? 1 : -1;
continue;
} else if (aInt > bInt) {
return 1;
} else {
return -1;
}
}
return 0;
}
/**
* Find and require a module which name starts with the provided name.
* If multiple modules exists, the highest semver is used.
* This function can only be used for remote dependencies.
* @param {String} name - module name: `user~repo`
* @param {Boolean} returnPath - returns the canonical require path if true,
* otherwise it returns the epxorted module
*/
require.latest = function (name, returnPath) {
function showError(name) {
throw new Error('failed to find latest module of "' + name + '"');
}
// only remotes with semvers, ignore local files conataining a '/'
var versionRegexp = /(.*)~(.*)@v?(\d+\.\d+\.\d+[^\/]*)$/;
var remoteRegexp = /(.*)~(.*)/;
if (!remoteRegexp.test(name)) showError(name);
var moduleNames = Object.keys(require.modules);
var semVerCandidates = [];
var otherCandidates = []; // for instance: name of the git branch
for (var i=0; i<moduleNames.length; i++) {
var moduleName = moduleNames[i];
if (new RegExp(name + '@').test(moduleName)) {
var version = moduleName.substr(name.length+1);
var semVerMatch = versionRegexp.exec(moduleName);
if (semVerMatch != null) {
semVerCandidates.push({version: version, name: moduleName});
} else {
otherCandidates.push({version: version, name: moduleName});
}
}
}
if (semVerCandidates.concat(otherCandidates).length === 0) {
showError(name);
}
if (semVerCandidates.length > 0) {
var module = semVerCandidates.sort(require.helper.semVerSort).pop().name;
if (returnPath === true) {
return module;
}
return require(module);
}
// if the build contains more than one branch of the same module
// you should not use this funciton
var module = otherCandidates.sort(function(a, b) {return a.name > b.name})[0].name;
if (returnPath === true) {
return module;
}
return require(module);
}
/**
* Registered modules.

@@ -150,4 +233,4 @@ */

var domify = require("component~domify@1.2.2");
var tpl = require("example/main.hbs");
var domify = require('component~domify@1.2.2');
var tpl = require('example/main.hbs');

@@ -168,40 +251,24 @@ document.querySelector('#app').appendChild(

require.register("example/main.hbs", function (exports, module) {
module.exports = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); partials = this.merge(partials, Handlebars.partials); data = data || {};
var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
function program1(depth0,data) {
var buffer = "";
buffer += "\n <li>"
+ escapeExpression((typeof depth0 === functionType ? depth0.apply(depth0) : depth0))
module.exports = Handlebars.template({"1":function(depth0,helpers,partials,data) {
return " <li>"
+ this.escapeExpression(this.lambda(depth0, depth0))
+ "</li>\n";
return buffer;
}
},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1;
stack1 = self.invokePartial(partials['example/_header'], 'example/_header', depth0, helpers, partials, data);
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n\n<ul>\n";
stack1 = helpers.each.call(depth0, (depth0 && depth0.users), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n</ul>\n";
return buffer;
})
return ((stack1 = this.invokePartial(partials['example/_header'],depth0,{"name":"example/_header","data":data,"helpers":helpers,"partials":partials})) != null ? stack1 : "")
+ "\n<ul>\n"
+ ((stack1 = helpers.each.call(depth0,(depth0 != null ? depth0.users : depth0),{"name":"each","hash":{},"fn":this.program(1, data, 0),"inverse":this.noop,"data":data})) != null ? stack1 : "")
+ "</ul>\n";
},"usePartial":true,"useData":true})
});
require.register("example/_header.hbs", function (exports, module) {
Handlebars.registerPartial("example/_header", Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
var buffer = "", stack1, helper, functionType="function", escapeExpression=this.escapeExpression;
Handlebars.registerPartial("example/_header", Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var helper;
buffer += "<h1>";
if (helper = helpers.title) { stack1 = helper.call(depth0, {hash:{},data:data}); }
else { helper = (depth0 && depth0.title); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
buffer += escapeExpression(stack1)
return "<h1>"
+ this.escapeExpression(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0,{"name":"title","hash":{},"data":data}) : helper)))
+ "</h1>\n";
return buffer;
}));
},"useData":true}));

@@ -212,5 +279,5 @@ });

handlebars v1.3.0
handlebars v3.0.0
Copyright (C) 2011 by Yehuda Katz
Copyright (C) 2011-2014 by Yehuda Katz

@@ -238,27 +305,16 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

/* exported Handlebars */
var Handlebars = (function() {
// handlebars/safe-string.js
var __module3__ = (function() {
"use strict";
var __exports__;
// Build out our basic SafeString type
function SafeString(string) {
this.string = string;
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.Handlebars = factory();
}
SafeString.prototype.toString = function() {
return "" + this.string;
};
__exports__ = SafeString;
return __exports__;
})();
}(this, function () {
// handlebars/utils.js
var __module2__ = (function(__dependency1__) {
var __module2__ = (function() {
"use strict";
var __exports__ = {};
/*jshint -W004 */
var SafeString = __dependency1__;
var escape = {

@@ -277,11 +333,15 @@ "&": "&amp;",

function escapeChar(chr) {
return escape[chr] || "&amp;";
return escape[chr];
}
function extend(obj, value) {
for(var key in value) {
if(Object.prototype.hasOwnProperty.call(value, key)) {
obj[key] = value[key];
function extend(obj /* , ...source */) {
for (var i = 1; i < arguments.length; i++) {
for (var key in arguments[i]) {
if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {
obj[key] = arguments[i][key];
}
}
}
return obj;
}

@@ -297,2 +357,3 @@

// fallback for older versions of Chrome and Safari
/* istanbul ignore next */
if (isFunction(/x/)) {

@@ -305,2 +366,3 @@ isFunction = function(value) {

__exports__.isFunction = isFunction;
/* istanbul ignore next */
var isArray = Array.isArray || function(value) {

@@ -310,9 +372,21 @@ return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;

__exports__.isArray = isArray;
// Older IE versions do not directly support indexOf so we must implement our own, sadly.
function indexOf(array, value) {
for (var i = 0, len = array.length; i < len; i++) {
if (array[i] === value) {
return i;
}
}
return -1;
}
__exports__.indexOf = indexOf;
function escapeExpression(string) {
// don't escape SafeStrings, since they're already safe
if (string instanceof SafeString) {
return string.toString();
} else if (!string && string !== 0) {
if (string && string.toHTML) {
return string.toHTML();
} else if (string == null) {
return "";
} else if (!string) {
return string + '';
}

@@ -339,8 +413,17 @@

__exports__.isEmpty = isEmpty;
__exports__.isEmpty = isEmpty;function blockParams(params, ids) {
params.path = ids;
return params;
}
__exports__.blockParams = blockParams;function appendContextPath(contextPath, id) {
return (contextPath ? contextPath + '.' : '') + id;
}
__exports__.appendContextPath = appendContextPath;
return __exports__;
})(__module3__);
})();
// handlebars/exception.js
var __module4__ = (function() {
var __module3__ = (function() {
"use strict";

@@ -352,7 +435,10 @@ var __exports__;

function Exception(message, node) {
var line;
if (node && node.firstLine) {
line = node.firstLine;
var loc = node && node.loc,
line,
column;
if (loc) {
line = loc.start.line;
column = loc.start.column;
message += ' - ' + line + ':' + node.firstColumn;
message += ' - ' + line + ':' + column;
}

@@ -367,5 +453,5 @@

if (line) {
if (loc) {
this.lineNumber = line;
this.column = node.firstColumn;
this.column = column;
}

@@ -387,4 +473,4 @@ }

var VERSION = "1.3.0";
__exports__.VERSION = VERSION;var COMPILER_REVISION = 4;
var VERSION = "3.0.0";
__exports__.VERSION = VERSION;var COMPILER_REVISION = 6;
__exports__.COMPILER_REVISION = COMPILER_REVISION;

@@ -395,3 +481,5 @@ var REVISION_CHANGES = {

3: '== 1.0.0-rc.4',
4: '>= 1.0.0'
4: '== 1.x.x',
5: '== 2.0.0-alpha.x',
6: '>= 2.0.0-beta.1'
};

@@ -417,18 +505,26 @@ __exports__.REVISION_CHANGES = REVISION_CHANGES;

registerHelper: function(name, fn, inverse) {
registerHelper: function(name, fn) {
if (toString.call(name) === objectType) {
if (inverse || fn) { throw new Exception('Arg not supported with multiple helpers'); }
if (fn) { throw new Exception('Arg not supported with multiple helpers'); }
Utils.extend(this.helpers, name);
} else {
if (inverse) { fn.not = inverse; }
this.helpers[name] = fn;
}
},
unregisterHelper: function(name) {
delete this.helpers[name];
},
registerPartial: function(name, str) {
registerPartial: function(name, partial) {
if (toString.call(name) === objectType) {
Utils.extend(this.partials, name);
} else {
this.partials[name] = str;
if (typeof partial === 'undefined') {
throw new Exception('Attempting to register a partial as undefined');
}
this.partials[name] = partial;
}
},
unregisterPartial: function(name) {
delete this.partials[name];
}

@@ -438,7 +534,9 @@ };

function registerDefaultHelpers(instance) {
instance.registerHelper('helperMissing', function(arg) {
if(arguments.length === 2) {
instance.registerHelper('helperMissing', function(/* [args, ]options */) {
if(arguments.length === 1) {
// A missing field in a {{foo}} constuct.
return undefined;
} else {
throw new Exception("Missing helper: '" + arg + "'");
// Someone is actually trying to call something, blow up.
throw new Exception("Missing helper: '" + arguments[arguments.length-1].name + "'");
}

@@ -448,6 +546,5 @@ });

instance.registerHelper('blockHelperMissing', function(context, options) {
var inverse = options.inverse || function() {}, fn = options.fn;
var inverse = options.inverse,
fn = options.fn;
if (isFunction(context)) { context = context.call(this); }
if(context === true) {

@@ -459,2 +556,6 @@ return fn(this);

if(context.length > 0) {
if (options.ids) {
options.ids = [options.name];
}
return instance.helpers.each(context, options);

@@ -465,3 +566,9 @@ } else {

} else {
return fn(context);
if (options.data && options.ids) {
var data = createFrame(options.data);
data.contextPath = Utils.appendContextPath(options.data.contextPath, options.name);
options = {data: data};
}
return fn(context, options);
}

@@ -471,5 +578,14 @@ });

instance.registerHelper('each', function(context, options) {
if (!options) {
throw new Exception('Must pass iterator to #each');
}
var fn = options.fn, inverse = options.inverse;
var i = 0, ret = "", data;
var contextPath;
if (options.data && options.ids) {
contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]) + '.';
}
if (isFunction(context)) { context = context.call(this); }

@@ -481,24 +597,43 @@

function execIteration(key, i, last) {
if (data) {
data.key = key;
data.index = i;
data.first = i === 0;
data.last = !!last;
if (contextPath) {
data.contextPath = contextPath + key;
}
}
ret = ret + fn(context[key], {
data: data,
blockParams: Utils.blockParams([context[key], key], [contextPath + key, null])
});
}
if(context && typeof context === 'object') {
if (isArray(context)) {
for(var j = context.length; i<j; i++) {
if (data) {
data.index = i;
data.first = (i === 0);
data.last = (i === (context.length-1));
}
ret = ret + fn(context[i], { data: data });
execIteration(i, i, i === context.length-1);
}
} else {
var priorKey;
for(var key in context) {
if(context.hasOwnProperty(key)) {
if(data) {
data.key = key;
data.index = i;
data.first = (i === 0);
// We're running the iterations one step out of sync so we can detect
// the last iteration without have to scan the object twice and create
// an itermediate keys array.
if (priorKey) {
execIteration(priorKey, i-1);
}
ret = ret + fn(context[key], {data: data});
priorKey = key;
i++;
}
}
if (priorKey) {
execIteration(priorKey, i-1, true);
}
}

@@ -534,9 +669,25 @@ }

if (!Utils.isEmpty(context)) return options.fn(context);
var fn = options.fn;
if (!Utils.isEmpty(context)) {
if (options.data && options.ids) {
var data = createFrame(options.data);
data.contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]);
options = {data:data};
}
return fn(context, options);
} else {
return options.inverse(this);
}
});
instance.registerHelper('log', function(context, options) {
instance.registerHelper('log', function(message, options) {
var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1;
instance.log(level, context);
instance.log(level, message);
});
instance.registerHelper('lookup', function(obj, field) {
return obj && obj[field];
});
}

@@ -552,11 +703,9 @@

ERROR: 3,
level: 3,
level: 1,
// can be overridden in the host environment
log: function(level, obj) {
if (logger.level <= level) {
// Can be overridden in the host environment
log: function(level, message) {
if (typeof console !== 'undefined' && logger.level <= level) {
var method = logger.methodMap[level];
if (typeof console !== 'undefined' && console[method]) {
console[method].call(console, obj);
}
(console[method] || console.log).call(console, message);
}

@@ -566,13 +715,30 @@ }

__exports__.logger = logger;
function log(level, obj) { logger.log(level, obj); }
__exports__.log = log;var createFrame = function(object) {
var obj = {};
Utils.extend(obj, object);
return obj;
var log = logger.log;
__exports__.log = log;
var createFrame = function(object) {
var frame = Utils.extend({}, object);
frame._parent = object;
return frame;
};
__exports__.createFrame = createFrame;
return __exports__;
})(__module2__, __module4__);
})(__module2__, __module3__);
// handlebars/safe-string.js
var __module4__ = (function() {
"use strict";
var __exports__;
// Build out our basic SafeString type
function SafeString(string) {
this.string = string;
}
SafeString.prototype.toString = SafeString.prototype.toHTML = function() {
return "" + this.string;
};
__exports__ = SafeString;
return __exports__;
})();
// handlebars/runtime.js

@@ -586,2 +752,3 @@ var __module5__ = (function(__dependency1__, __dependency2__, __dependency3__) {

var REVISION_CHANGES = __dependency3__.REVISION_CHANGES;
var createFrame = __dependency3__.createFrame;

@@ -609,18 +776,41 @@ function checkRevision(compilerInfo) {

function template(templateSpec, env) {
/* istanbul ignore next */
if (!env) {
throw new Exception("No environment passed to template");
}
if (!templateSpec || !templateSpec.main) {
throw new Exception('Unknown template object: ' + typeof templateSpec);
}
// Note: Using env.VM references rather than local var references throughout this section to allow
// for external users to override these as psuedo-supported APIs.
var invokePartialWrapper = function(partial, name, context, helpers, partials, data) {
var result = env.VM.invokePartial.apply(this, arguments);
if (result != null) { return result; }
env.VM.checkRevision(templateSpec.compiler);
if (env.compile) {
var options = { helpers: helpers, partials: partials, data: data };
partials[name] = env.compile(partial, { data: data !== undefined }, env);
return partials[name](context, options);
var invokePartialWrapper = function(partial, context, options) {
if (options.hash) {
context = Utils.extend({}, context, options.hash);
}
partial = env.VM.resolvePartial.call(this, partial, context, options);
var result = env.VM.invokePartial.call(this, partial, context, options);
if (result == null && env.compile) {
options.partials[options.name] = env.compile(partial, templateSpec.compilerOptions, env);
result = options.partials[options.name](context, options);
}
if (result != null) {
if (options.indent) {
var lines = result.split('\n');
for (var i = 0, l = lines.length; i < l; i++) {
if (!lines[i] && i + 1 === l) {
break;
}
lines[i] = options.indent + lines[i];
}
result = lines.join('\n');
}
return result;
} else {
throw new Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
throw new Exception("The partial " + options.name + " could not be compiled when running in runtime-only mode");
}

@@ -631,14 +821,45 @@ };

var container = {
strict: function(obj, name) {
if (!(name in obj)) {
throw new Exception('"' + name + '" not defined in ' + obj);
}
return obj[name];
},
lookup: function(depths, name) {
var len = depths.length;
for (var i = 0; i < len; i++) {
if (depths[i] && depths[i][name] != null) {
return depths[i][name];
}
}
},
lambda: function(current, context) {
return typeof current === 'function' ? current.call(context) : current;
},
escapeExpression: Utils.escapeExpression,
invokePartial: invokePartialWrapper,
fn: function(i) {
return templateSpec[i];
},
programs: [],
program: function(i, fn, data) {
var programWrapper = this.programs[i];
if(data) {
programWrapper = program(i, fn, data);
program: function(i, data, declaredBlockParams, blockParams, depths) {
var programWrapper = this.programs[i],
fn = this.fn(i);
if (data || depths || blockParams || declaredBlockParams) {
programWrapper = program(this, i, fn, data, declaredBlockParams, blockParams, depths);
} else if (!programWrapper) {
programWrapper = this.programs[i] = program(i, fn);
programWrapper = this.programs[i] = program(this, i, fn);
}
return programWrapper;
},
data: function(data, depth) {
while (data && depth--) {
data = data._parent;
}
return data;
},
merge: function(param, common) {

@@ -648,67 +869,89 @@ var ret = param || common;

if (param && common && (param !== common)) {
ret = {};
Utils.extend(ret, common);
Utils.extend(ret, param);
ret = Utils.extend({}, common, param);
}
return ret;
},
programWithDepth: env.VM.programWithDepth,
noop: env.VM.noop,
compilerInfo: null
compilerInfo: templateSpec.compiler
};
return function(context, options) {
var ret = function(context, options) {
options = options || {};
var namespace = options.partial ? options : env,
helpers,
partials;
var data = options.data;
if (!options.partial) {
helpers = options.helpers;
partials = options.partials;
ret._setup(options);
if (!options.partial && templateSpec.useData) {
data = initData(context, data);
}
var result = templateSpec.call(
container,
namespace, context,
helpers,
partials,
options.data);
var depths,
blockParams = templateSpec.useBlockParams ? [] : undefined;
if (templateSpec.useDepths) {
depths = options.depths ? [context].concat(options.depths) : [context];
}
return templateSpec.main.call(container, context, container.helpers, container.partials, data, blockParams, depths);
};
ret.isTop = true;
ret._setup = function(options) {
if (!options.partial) {
env.VM.checkRevision(container.compilerInfo);
container.helpers = container.merge(options.helpers, env.helpers);
if (templateSpec.usePartial) {
container.partials = container.merge(options.partials, env.partials);
}
} else {
container.helpers = options.helpers;
container.partials = options.partials;
}
return result;
};
}
__exports__.template = template;function programWithDepth(i, fn, data /*, $depth */) {
var args = Array.prototype.slice.call(arguments, 3);
ret._child = function(i, data, blockParams, depths) {
if (templateSpec.useBlockParams && !blockParams) {
throw new Exception('must pass block params');
}
if (templateSpec.useDepths && !depths) {
throw new Exception('must pass parent depths');
}
var prog = function(context, options) {
options = options || {};
return fn.apply(this, [context, options.data || data].concat(args));
return program(container, i, templateSpec[i], data, 0, blockParams, depths);
};
prog.program = i;
prog.depth = args.length;
return prog;
return ret;
}
__exports__.programWithDepth = programWithDepth;function program(i, fn, data) {
__exports__.template = template;function program(container, i, fn, data, declaredBlockParams, blockParams, depths) {
var prog = function(context, options) {
options = options || {};
return fn(context, options.data || data);
return fn.call(container,
context,
container.helpers, container.partials,
options.data || data,
blockParams && [options.blockParams].concat(blockParams),
depths && [context].concat(depths));
};
prog.program = i;
prog.depth = 0;
prog.depth = depths ? depths.length : 0;
prog.blockParams = declaredBlockParams || 0;
return prog;
}
__exports__.program = program;function invokePartial(partial, name, context, helpers, partials, data) {
var options = { partial: true, helpers: helpers, partials: partials, data: data };
__exports__.program = program;function resolvePartial(partial, context, options) {
if (!partial) {
partial = options.partials[options.name];
} else if (!partial.call && !options.name) {
// This is a dynamic partial that returned a string
options.name = partial;
partial = options.partials[partial];
}
return partial;
}
__exports__.resolvePartial = resolvePartial;function invokePartial(partial, context, options) {
options.partial = true;
if(partial === undefined) {
throw new Exception("The partial " + name + " could not be found");
throw new Exception("The partial " + options.name + " could not be found");
} else if(partial instanceof Function) {

@@ -721,5 +964,11 @@ return partial(context, options);

__exports__.noop = noop;
__exports__.noop = noop;function initData(context, data) {
if (!data || !('root' in data)) {
data = data ? createFrame(data) : {};
data.root = context;
}
return data;
}
return __exports__;
})(__module2__, __module4__, __module1__);
})(__module2__, __module3__, __module1__);

@@ -748,2 +997,3 @@ // handlebars.runtime.js

hb.Utils = Utils;
hb.escapeExpression = Utils.escapeExpression;

@@ -761,10 +1011,23 @@ hb.VM = runtime;

/*jshint -W040 */
/* istanbul ignore next */
var root = typeof global !== 'undefined' ? global : window,
$Handlebars = root.Handlebars;
/* istanbul ignore next */
Handlebars.noConflict = function() {
if (root.Handlebars === Handlebars) {
root.Handlebars = $Handlebars;
}
};
Handlebars['default'] = Handlebars;
__exports__ = Handlebars;
return __exports__;
})(__module1__, __module3__, __module4__, __module2__, __module5__);
})(__module1__, __module4__, __module3__, __module2__, __module5__);
return __module0__;
})();
}));
this.Handlebars = window.Handlebars = Handlebars;
require("example/_header.hbs");
require("example")
/*!
handlebars v1.3.0
handlebars v3.0.0
Copyright (C) 2011 by Yehuda Katz
Copyright (C) 2011-2014 by Yehuda Katz

@@ -28,27 +28,16 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

/* exported Handlebars */
var Handlebars = (function() {
// handlebars/safe-string.js
var __module3__ = (function() {
"use strict";
var __exports__;
// Build out our basic SafeString type
function SafeString(string) {
this.string = string;
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.Handlebars = factory();
}
SafeString.prototype.toString = function() {
return "" + this.string;
};
__exports__ = SafeString;
return __exports__;
})();
}(this, function () {
// handlebars/utils.js
var __module2__ = (function(__dependency1__) {
var __module2__ = (function() {
"use strict";
var __exports__ = {};
/*jshint -W004 */
var SafeString = __dependency1__;
var escape = {

@@ -67,11 +56,15 @@ "&": "&amp;",

function escapeChar(chr) {
return escape[chr] || "&amp;";
return escape[chr];
}
function extend(obj, value) {
for(var key in value) {
if(Object.prototype.hasOwnProperty.call(value, key)) {
obj[key] = value[key];
function extend(obj /* , ...source */) {
for (var i = 1; i < arguments.length; i++) {
for (var key in arguments[i]) {
if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {
obj[key] = arguments[i][key];
}
}
}
return obj;
}

@@ -87,2 +80,3 @@

// fallback for older versions of Chrome and Safari
/* istanbul ignore next */
if (isFunction(/x/)) {

@@ -95,2 +89,3 @@ isFunction = function(value) {

__exports__.isFunction = isFunction;
/* istanbul ignore next */
var isArray = Array.isArray || function(value) {

@@ -100,9 +95,21 @@ return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;

__exports__.isArray = isArray;
// Older IE versions do not directly support indexOf so we must implement our own, sadly.
function indexOf(array, value) {
for (var i = 0, len = array.length; i < len; i++) {
if (array[i] === value) {
return i;
}
}
return -1;
}
__exports__.indexOf = indexOf;
function escapeExpression(string) {
// don't escape SafeStrings, since they're already safe
if (string instanceof SafeString) {
return string.toString();
} else if (!string && string !== 0) {
if (string && string.toHTML) {
return string.toHTML();
} else if (string == null) {
return "";
} else if (!string) {
return string + '';
}

@@ -129,8 +136,17 @@

__exports__.isEmpty = isEmpty;
__exports__.isEmpty = isEmpty;function blockParams(params, ids) {
params.path = ids;
return params;
}
__exports__.blockParams = blockParams;function appendContextPath(contextPath, id) {
return (contextPath ? contextPath + '.' : '') + id;
}
__exports__.appendContextPath = appendContextPath;
return __exports__;
})(__module3__);
})();
// handlebars/exception.js
var __module4__ = (function() {
var __module3__ = (function() {
"use strict";

@@ -142,7 +158,10 @@ var __exports__;

function Exception(message, node) {
var line;
if (node && node.firstLine) {
line = node.firstLine;
var loc = node && node.loc,
line,
column;
if (loc) {
line = loc.start.line;
column = loc.start.column;
message += ' - ' + line + ':' + node.firstColumn;
message += ' - ' + line + ':' + column;
}

@@ -157,5 +176,5 @@

if (line) {
if (loc) {
this.lineNumber = line;
this.column = node.firstColumn;
this.column = column;
}

@@ -177,4 +196,4 @@ }

var VERSION = "1.3.0";
__exports__.VERSION = VERSION;var COMPILER_REVISION = 4;
var VERSION = "3.0.0";
__exports__.VERSION = VERSION;var COMPILER_REVISION = 6;
__exports__.COMPILER_REVISION = COMPILER_REVISION;

@@ -185,3 +204,5 @@ var REVISION_CHANGES = {

3: '== 1.0.0-rc.4',
4: '>= 1.0.0'
4: '== 1.x.x',
5: '== 2.0.0-alpha.x',
6: '>= 2.0.0-beta.1'
};

@@ -207,18 +228,26 @@ __exports__.REVISION_CHANGES = REVISION_CHANGES;

registerHelper: function(name, fn, inverse) {
registerHelper: function(name, fn) {
if (toString.call(name) === objectType) {
if (inverse || fn) { throw new Exception('Arg not supported with multiple helpers'); }
if (fn) { throw new Exception('Arg not supported with multiple helpers'); }
Utils.extend(this.helpers, name);
} else {
if (inverse) { fn.not = inverse; }
this.helpers[name] = fn;
}
},
unregisterHelper: function(name) {
delete this.helpers[name];
},
registerPartial: function(name, str) {
registerPartial: function(name, partial) {
if (toString.call(name) === objectType) {
Utils.extend(this.partials, name);
} else {
this.partials[name] = str;
if (typeof partial === 'undefined') {
throw new Exception('Attempting to register a partial as undefined');
}
this.partials[name] = partial;
}
},
unregisterPartial: function(name) {
delete this.partials[name];
}

@@ -228,7 +257,9 @@ };

function registerDefaultHelpers(instance) {
instance.registerHelper('helperMissing', function(arg) {
if(arguments.length === 2) {
instance.registerHelper('helperMissing', function(/* [args, ]options */) {
if(arguments.length === 1) {
// A missing field in a {{foo}} constuct.
return undefined;
} else {
throw new Exception("Missing helper: '" + arg + "'");
// Someone is actually trying to call something, blow up.
throw new Exception("Missing helper: '" + arguments[arguments.length-1].name + "'");
}

@@ -238,6 +269,5 @@ });

instance.registerHelper('blockHelperMissing', function(context, options) {
var inverse = options.inverse || function() {}, fn = options.fn;
var inverse = options.inverse,
fn = options.fn;
if (isFunction(context)) { context = context.call(this); }
if(context === true) {

@@ -249,2 +279,6 @@ return fn(this);

if(context.length > 0) {
if (options.ids) {
options.ids = [options.name];
}
return instance.helpers.each(context, options);

@@ -255,3 +289,9 @@ } else {

} else {
return fn(context);
if (options.data && options.ids) {
var data = createFrame(options.data);
data.contextPath = Utils.appendContextPath(options.data.contextPath, options.name);
options = {data: data};
}
return fn(context, options);
}

@@ -261,5 +301,14 @@ });

instance.registerHelper('each', function(context, options) {
if (!options) {
throw new Exception('Must pass iterator to #each');
}
var fn = options.fn, inverse = options.inverse;
var i = 0, ret = "", data;
var contextPath;
if (options.data && options.ids) {
contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]) + '.';
}
if (isFunction(context)) { context = context.call(this); }

@@ -271,24 +320,43 @@

function execIteration(key, i, last) {
if (data) {
data.key = key;
data.index = i;
data.first = i === 0;
data.last = !!last;
if (contextPath) {
data.contextPath = contextPath + key;
}
}
ret = ret + fn(context[key], {
data: data,
blockParams: Utils.blockParams([context[key], key], [contextPath + key, null])
});
}
if(context && typeof context === 'object') {
if (isArray(context)) {
for(var j = context.length; i<j; i++) {
if (data) {
data.index = i;
data.first = (i === 0);
data.last = (i === (context.length-1));
}
ret = ret + fn(context[i], { data: data });
execIteration(i, i, i === context.length-1);
}
} else {
var priorKey;
for(var key in context) {
if(context.hasOwnProperty(key)) {
if(data) {
data.key = key;
data.index = i;
data.first = (i === 0);
// We're running the iterations one step out of sync so we can detect
// the last iteration without have to scan the object twice and create
// an itermediate keys array.
if (priorKey) {
execIteration(priorKey, i-1);
}
ret = ret + fn(context[key], {data: data});
priorKey = key;
i++;
}
}
if (priorKey) {
execIteration(priorKey, i-1, true);
}
}

@@ -324,9 +392,25 @@ }

if (!Utils.isEmpty(context)) return options.fn(context);
var fn = options.fn;
if (!Utils.isEmpty(context)) {
if (options.data && options.ids) {
var data = createFrame(options.data);
data.contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]);
options = {data:data};
}
return fn(context, options);
} else {
return options.inverse(this);
}
});
instance.registerHelper('log', function(context, options) {
instance.registerHelper('log', function(message, options) {
var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1;
instance.log(level, context);
instance.log(level, message);
});
instance.registerHelper('lookup', function(obj, field) {
return obj && obj[field];
});
}

@@ -342,11 +426,9 @@

ERROR: 3,
level: 3,
level: 1,
// can be overridden in the host environment
log: function(level, obj) {
if (logger.level <= level) {
// Can be overridden in the host environment
log: function(level, message) {
if (typeof console !== 'undefined' && logger.level <= level) {
var method = logger.methodMap[level];
if (typeof console !== 'undefined' && console[method]) {
console[method].call(console, obj);
}
(console[method] || console.log).call(console, message);
}

@@ -356,13 +438,30 @@ }

__exports__.logger = logger;
function log(level, obj) { logger.log(level, obj); }
__exports__.log = log;var createFrame = function(object) {
var obj = {};
Utils.extend(obj, object);
return obj;
var log = logger.log;
__exports__.log = log;
var createFrame = function(object) {
var frame = Utils.extend({}, object);
frame._parent = object;
return frame;
};
__exports__.createFrame = createFrame;
return __exports__;
})(__module2__, __module4__);
})(__module2__, __module3__);
// handlebars/safe-string.js
var __module4__ = (function() {
"use strict";
var __exports__;
// Build out our basic SafeString type
function SafeString(string) {
this.string = string;
}
SafeString.prototype.toString = SafeString.prototype.toHTML = function() {
return "" + this.string;
};
__exports__ = SafeString;
return __exports__;
})();
// handlebars/runtime.js

@@ -376,2 +475,3 @@ var __module5__ = (function(__dependency1__, __dependency2__, __dependency3__) {

var REVISION_CHANGES = __dependency3__.REVISION_CHANGES;
var createFrame = __dependency3__.createFrame;

@@ -399,18 +499,41 @@ function checkRevision(compilerInfo) {

function template(templateSpec, env) {
/* istanbul ignore next */
if (!env) {
throw new Exception("No environment passed to template");
}
if (!templateSpec || !templateSpec.main) {
throw new Exception('Unknown template object: ' + typeof templateSpec);
}
// Note: Using env.VM references rather than local var references throughout this section to allow
// for external users to override these as psuedo-supported APIs.
var invokePartialWrapper = function(partial, name, context, helpers, partials, data) {
var result = env.VM.invokePartial.apply(this, arguments);
if (result != null) { return result; }
env.VM.checkRevision(templateSpec.compiler);
if (env.compile) {
var options = { helpers: helpers, partials: partials, data: data };
partials[name] = env.compile(partial, { data: data !== undefined }, env);
return partials[name](context, options);
var invokePartialWrapper = function(partial, context, options) {
if (options.hash) {
context = Utils.extend({}, context, options.hash);
}
partial = env.VM.resolvePartial.call(this, partial, context, options);
var result = env.VM.invokePartial.call(this, partial, context, options);
if (result == null && env.compile) {
options.partials[options.name] = env.compile(partial, templateSpec.compilerOptions, env);
result = options.partials[options.name](context, options);
}
if (result != null) {
if (options.indent) {
var lines = result.split('\n');
for (var i = 0, l = lines.length; i < l; i++) {
if (!lines[i] && i + 1 === l) {
break;
}
lines[i] = options.indent + lines[i];
}
result = lines.join('\n');
}
return result;
} else {
throw new Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
throw new Exception("The partial " + options.name + " could not be compiled when running in runtime-only mode");
}

@@ -421,14 +544,45 @@ };

var container = {
strict: function(obj, name) {
if (!(name in obj)) {
throw new Exception('"' + name + '" not defined in ' + obj);
}
return obj[name];
},
lookup: function(depths, name) {
var len = depths.length;
for (var i = 0; i < len; i++) {
if (depths[i] && depths[i][name] != null) {
return depths[i][name];
}
}
},
lambda: function(current, context) {
return typeof current === 'function' ? current.call(context) : current;
},
escapeExpression: Utils.escapeExpression,
invokePartial: invokePartialWrapper,
fn: function(i) {
return templateSpec[i];
},
programs: [],
program: function(i, fn, data) {
var programWrapper = this.programs[i];
if(data) {
programWrapper = program(i, fn, data);
program: function(i, data, declaredBlockParams, blockParams, depths) {
var programWrapper = this.programs[i],
fn = this.fn(i);
if (data || depths || blockParams || declaredBlockParams) {
programWrapper = program(this, i, fn, data, declaredBlockParams, blockParams, depths);
} else if (!programWrapper) {
programWrapper = this.programs[i] = program(i, fn);
programWrapper = this.programs[i] = program(this, i, fn);
}
return programWrapper;
},
data: function(data, depth) {
while (data && depth--) {
data = data._parent;
}
return data;
},
merge: function(param, common) {

@@ -438,67 +592,89 @@ var ret = param || common;

if (param && common && (param !== common)) {
ret = {};
Utils.extend(ret, common);
Utils.extend(ret, param);
ret = Utils.extend({}, common, param);
}
return ret;
},
programWithDepth: env.VM.programWithDepth,
noop: env.VM.noop,
compilerInfo: null
compilerInfo: templateSpec.compiler
};
return function(context, options) {
var ret = function(context, options) {
options = options || {};
var namespace = options.partial ? options : env,
helpers,
partials;
var data = options.data;
if (!options.partial) {
helpers = options.helpers;
partials = options.partials;
ret._setup(options);
if (!options.partial && templateSpec.useData) {
data = initData(context, data);
}
var result = templateSpec.call(
container,
namespace, context,
helpers,
partials,
options.data);
var depths,
blockParams = templateSpec.useBlockParams ? [] : undefined;
if (templateSpec.useDepths) {
depths = options.depths ? [context].concat(options.depths) : [context];
}
return templateSpec.main.call(container, context, container.helpers, container.partials, data, blockParams, depths);
};
ret.isTop = true;
ret._setup = function(options) {
if (!options.partial) {
env.VM.checkRevision(container.compilerInfo);
container.helpers = container.merge(options.helpers, env.helpers);
if (templateSpec.usePartial) {
container.partials = container.merge(options.partials, env.partials);
}
} else {
container.helpers = options.helpers;
container.partials = options.partials;
}
return result;
};
}
__exports__.template = template;function programWithDepth(i, fn, data /*, $depth */) {
var args = Array.prototype.slice.call(arguments, 3);
ret._child = function(i, data, blockParams, depths) {
if (templateSpec.useBlockParams && !blockParams) {
throw new Exception('must pass block params');
}
if (templateSpec.useDepths && !depths) {
throw new Exception('must pass parent depths');
}
var prog = function(context, options) {
options = options || {};
return fn.apply(this, [context, options.data || data].concat(args));
return program(container, i, templateSpec[i], data, 0, blockParams, depths);
};
prog.program = i;
prog.depth = args.length;
return prog;
return ret;
}
__exports__.programWithDepth = programWithDepth;function program(i, fn, data) {
__exports__.template = template;function program(container, i, fn, data, declaredBlockParams, blockParams, depths) {
var prog = function(context, options) {
options = options || {};
return fn(context, options.data || data);
return fn.call(container,
context,
container.helpers, container.partials,
options.data || data,
blockParams && [options.blockParams].concat(blockParams),
depths && [context].concat(depths));
};
prog.program = i;
prog.depth = 0;
prog.depth = depths ? depths.length : 0;
prog.blockParams = declaredBlockParams || 0;
return prog;
}
__exports__.program = program;function invokePartial(partial, name, context, helpers, partials, data) {
var options = { partial: true, helpers: helpers, partials: partials, data: data };
__exports__.program = program;function resolvePartial(partial, context, options) {
if (!partial) {
partial = options.partials[options.name];
} else if (!partial.call && !options.name) {
// This is a dynamic partial that returned a string
options.name = partial;
partial = options.partials[partial];
}
return partial;
}
__exports__.resolvePartial = resolvePartial;function invokePartial(partial, context, options) {
options.partial = true;
if(partial === undefined) {
throw new Exception("The partial " + name + " could not be found");
throw new Exception("The partial " + options.name + " could not be found");
} else if(partial instanceof Function) {

@@ -511,5 +687,11 @@ return partial(context, options);

__exports__.noop = noop;
__exports__.noop = noop;function initData(context, data) {
if (!data || !('root' in data)) {
data = data ? createFrame(data) : {};
data.root = context;
}
return data;
}
return __exports__;
})(__module2__, __module4__, __module1__);
})(__module2__, __module3__, __module1__);

@@ -538,2 +720,3 @@ // handlebars.runtime.js

hb.Utils = Utils;
hb.escapeExpression = Utils.escapeExpression;

@@ -551,7 +734,20 @@ hb.VM = runtime;

/*jshint -W040 */
/* istanbul ignore next */
var root = typeof global !== 'undefined' ? global : window,
$Handlebars = root.Handlebars;
/* istanbul ignore next */
Handlebars.noConflict = function() {
if (root.Handlebars === Handlebars) {
root.Handlebars = $Handlebars;
}
};
Handlebars['default'] = Handlebars;
__exports__ = Handlebars;
return __exports__;
})(__module1__, __module3__, __module4__, __module2__, __module5__);
})(__module1__, __module4__, __module3__, __module2__, __module5__);
return __module0__;
})();
}));
{
"name": "component-builder-handlebars",
"version": "0.4.0",
"version": "0.4.1",
"description": "Builder.js plugin to precompile Handlebars templates",

@@ -32,3 +32,3 @@ "author": {

"defaults": "^1.0.0",
"handlebars": "^1.3.0"
"handlebars": "^3.0.0"
},

@@ -35,0 +35,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc