@bigcommerce/stencil-paper
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -15,3 +15,3 @@ var _ = require('lodash'), | ||
internals.implementation.prototype.register = function(context) { | ||
internals.implementation.prototype.register = function () { | ||
this.handlebars.registerHelper('all', function () { | ||
@@ -18,0 +18,0 @@ |
@@ -15,3 +15,3 @@ var _ = require('lodash'), | ||
internals.implementation.prototype.register = function(context) { | ||
internals.implementation.prototype.register = function() { | ||
this.handlebars.registerHelper('any', function() { | ||
@@ -37,2 +37,3 @@ | ||
} else { | ||
// DEPRECATED: Moved to #or helper | ||
// Without options hash, we check all the arguments | ||
@@ -39,0 +40,0 @@ any = _.any(args, function(arg) { |
@@ -7,3 +7,3 @@ var internals = {}; | ||
internals.implementation.prototype.register = function(context) { | ||
internals.implementation.prototype.register = function() { | ||
var self = this; | ||
@@ -10,0 +10,0 @@ |
@@ -7,3 +7,3 @@ var internals = {}; | ||
internals.implementation.prototype.register = function(context) { | ||
internals.implementation.prototype.register = function() { | ||
this.handlebars.registerHelper('compare', function (lvalue, rvalue, options) { | ||
@@ -10,0 +10,0 @@ var operator, |
@@ -12,3 +12,3 @@ /** | ||
internals.implementation.prototype.register = function(context) { | ||
internals.implementation.prototype.register = function() { | ||
var self = this; | ||
@@ -15,0 +15,0 @@ |
@@ -16,4 +16,4 @@ var _ = require('lodash'), | ||
internals.implementation.prototype.register = function(context) { | ||
this.handlebars.registerHelper('contains', function(value, targetValue) { | ||
internals.implementation.prototype.register = function() { | ||
this.handlebars.registerHelper('contains', function() { | ||
var args = Array.prototype.slice.call(arguments, 0, -1), | ||
@@ -20,0 +20,0 @@ options = _.last(arguments), |
@@ -8,4 +8,4 @@ var _ = require('lodash'), | ||
internals.implementation.prototype.register = function(context) { | ||
this.handlebars.registerHelper('pick', function(object, predicate) { | ||
internals.implementation.prototype.register = function() { | ||
this.handlebars.registerHelper('pick', function() { | ||
return _.pick.apply(null, arguments); | ||
@@ -65,4 +65,3 @@ }); | ||
var out = '', | ||
i = start, | ||
iOut; | ||
i = start; | ||
@@ -69,0 +68,0 @@ for (i; i <= end; i++) { |
var Path = require('path'), | ||
_ = require('lodash'), | ||
internals = {}; | ||
@@ -9,8 +8,6 @@ | ||
internals.implementation.prototype.register = function(context, paper) { | ||
internals.implementation.prototype.register = function() { | ||
var self = this; | ||
this.handlebars.registerHelper('dynamicComponent', function(path) { | ||
var template; | ||
if (!this['partial']) { | ||
@@ -17,0 +14,0 @@ return; |
@@ -8,3 +8,3 @@ var _ = require('lodash'), | ||
internals.implementation.prototype.register = function(context) { | ||
internals.implementation.prototype.register = function() { | ||
this.handlebars.registerHelper('for', function(from, to, context, options) { | ||
@@ -11,0 +11,0 @@ var output = '', |
@@ -5,3 +5,3 @@ var helper = function (handlebars) { | ||
helper.prototype.register = function (context) { | ||
helper.prototype.register = function () { | ||
this.handlebars.registerHelper('helperMissing', function () { | ||
@@ -8,0 +8,0 @@ return undefined; |
@@ -8,3 +8,3 @@ var _ = require('lodash'), | ||
internals.implementation.prototype.register = function(context) { | ||
internals.implementation.prototype.register = function() { | ||
this.handlebars.registerHelper('if', function (lvalue, operator, rvalue, options) { | ||
@@ -11,0 +11,0 @@ var result; |
@@ -18,3 +18,3 @@ var internals = {}; | ||
this.handlebars.registerHelper('jsContext', function (options) { | ||
this.handlebars.registerHelper('jsContext', function () { | ||
@@ -21,0 +21,0 @@ var jsContext = JSON.stringify(JSON.stringify(paper.inject)); |
@@ -7,3 +7,3 @@ var internals = {}; | ||
internals.implementation.prototype.register = function(context) { | ||
internals.implementation.prototype.register = function() { | ||
this.handlebars.registerHelper('join', function(array, separator, options) { | ||
@@ -10,0 +10,0 @@ var config = options.hash || {}; |
@@ -7,3 +7,3 @@ var internals = {}; | ||
internals.implementation.prototype.register = function(context) { | ||
internals.implementation.prototype.register = function() { | ||
this.handlebars.registerHelper('json', function (data) { | ||
@@ -10,0 +10,0 @@ return JSON.stringify(data); |
@@ -15,3 +15,3 @@ var _ = require('lodash'), | ||
internals.implementation.prototype.register = function(context) { | ||
internals.implementation.prototype.register = function() { | ||
this.handlebars.registerHelper('limit', function(data, limit) { | ||
@@ -18,0 +18,0 @@ |
@@ -7,3 +7,3 @@ var internals = {}; | ||
internals.implementation.prototype.register = function(context) { | ||
internals.implementation.prototype.register = function() { | ||
var self = this; | ||
@@ -10,0 +10,0 @@ // https://github.com/danharper/Handlebars-Helpers/blob/master/src/helpers.js#L89 |
@@ -8,3 +8,3 @@ var _ = require('lodash'), | ||
internals.implementation.prototype.register = function(context) { | ||
internals.implementation.prototype.register = function() { | ||
this.handlebars.registerHelper('pluck', function(collection, path) { | ||
@@ -11,0 +11,0 @@ return _.pluck(collection, path); |
@@ -7,3 +7,3 @@ var internals = {}; | ||
internals.implementation.prototype.register = function(context) { | ||
internals.implementation.prototype.register = function() { | ||
var self = this; | ||
@@ -10,0 +10,0 @@ |
@@ -7,3 +7,3 @@ var internals = {}; | ||
internals.implementation.prototype.register = function(context) { | ||
internals.implementation.prototype.register = function() { | ||
this.handlebars.registerHelper('replace', function(needle, haystack, options) { | ||
@@ -10,0 +10,0 @@ var contains = false; |
@@ -1,3 +0,2 @@ | ||
var _ = require('lodash'), | ||
internals = {}; | ||
var internals = {}; | ||
@@ -8,5 +7,5 @@ internals.implementation = function(handlebars) { | ||
internals.implementation.prototype.register = function(context, paper) { | ||
internals.implementation.prototype.register = function() { | ||
this.handlebars.registerHelper('snippet', function(location, options) { | ||
this.handlebars.registerHelper('snippet', function(location) { | ||
return '<!-- snippet location ' + location + ' -->'; | ||
@@ -13,0 +12,0 @@ }); |
@@ -7,3 +7,3 @@ var internals = {}; | ||
internals.implementation.prototype.register = function(context) { | ||
internals.implementation.prototype.register = function() { | ||
this.handlebars.registerHelper('toLowerCase', function(string) { | ||
@@ -10,0 +10,0 @@ |
@@ -72,3 +72,3 @@ var _ = require('lodash'), | ||
eval('var template = ' + precompiled); | ||
self.handlebars.templates[path] = self.handlebars.template(template); | ||
self.handlebars.templates[path] = self.handlebars.template(template); // eslint-disable-line no-undef | ||
} | ||
@@ -117,3 +117,3 @@ }); | ||
// Make translations available to the helpers | ||
self.translate = Localizer(acceptLanguage, translations); | ||
self.translate = Localizer.localize(acceptLanguage, translations); | ||
@@ -120,0 +120,0 @@ callback(); |
@@ -12,5 +12,4 @@ var _ = require('lodash'), | ||
*/ | ||
module.exports = function (acceptLanguage, translations) { | ||
var compiledTranslations, | ||
preferredTranslation, | ||
function localize(acceptLanguage, translations) { | ||
var preferredTranslation, | ||
preferredLangs, | ||
@@ -43,4 +42,7 @@ suitableLang = 'en'; | ||
return internals.getTranslator(suitableLang, preferredTranslation); | ||
}; | ||
} | ||
module.exports.localize = localize; | ||
/** | ||
@@ -54,3 +56,2 @@ * This function will load all of the JSON nested locale files and flatten them | ||
var a = new Hoek.Timer(); | ||
_.forOwn(locales, function (localeData, localeName) { | ||
@@ -57,0 +58,0 @@ try { |
@@ -19,3 +19,3 @@ var Graph = require('tarjan-graph'); | ||
*/ | ||
StencilPrecompiler.prototype.precompile = function() { | ||
StencilPrecompiler.prototype.precompile = function () { | ||
checkParsedTemplatesDirectoryExists.call(this); | ||
@@ -116,3 +116,2 @@ detectCycles.call(this); | ||
var parsedContents; | ||
var partial; | ||
var prop; | ||
@@ -129,3 +128,2 @@ | ||
if (parsedContents.hasOwnProperty(prop)) { | ||
partial = parsedContents[prop]; | ||
precompiledMap[prop] = handlebars.precompile(parsedContents[prop], options); | ||
@@ -132,0 +130,0 @@ } |
{ | ||
"name": "@bigcommerce/stencil-paper", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "A stencil plugin to register partials and helpers from handlebars and returns the compiled version for the stencil platform.", | ||
@@ -9,3 +9,3 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "lab -l -t 80" | ||
"test": "lab -l -t 90" | ||
}, | ||
@@ -35,2 +35,7 @@ "repository": { | ||
"code": "^1.4.0", | ||
"eslint": "^2.7.0", | ||
"eslint-config-airbnb": "^6.2.0", | ||
"eslint-plugin-react": "^4.3.0", | ||
"gulp": "^3.9.1", | ||
"gulp-eslint": "^2.0.0", | ||
"lab": "^5.8.1", | ||
@@ -37,0 +42,0 @@ "sinon": "^1.17.2" |
# stencil-paper | ||
[![Build Status](https://travis-ci.org/bigcommerce/paper.svg?branch=master)](https://travis-ci.org/bigcommerce/paper) | ||
[![Build Status](https://travis-ci.org/bigcommerce/paper.svg?branch=master)](https://travis-ci.org/bigcommerce/paper) [![npm (scoped)](https://img.shields.io/npm/v/@bigcommerce/stencil-paper.svg)](https://www.npmjs.com/package/@bigcommerce/stencil-paper) | ||
@@ -4,0 +4,0 @@ *stencil-paper* is a plugin for `stencil-cli` and `stapler`. Its duty is to render the themes using [Handlebars](http://handlebarsjs.com/) template engine. |
@@ -52,2 +52,3 @@ var Code = require('code'), | ||
describe('any helper (with multiple arguments)', function() { | ||
// DEPRECATED: Moved to #or helper | ||
var context = { | ||
@@ -54,0 +55,0 @@ num1: 1, |
var Code = require('code'), | ||
Lab = require('lab'), | ||
Handlebars = require('handlebars'), | ||
Paper = require('../index'), | ||
@@ -11,13 +10,2 @@ lab = exports.lab = Lab.script(), | ||
describe('loadTheme()', function() { | ||
var templates = { | ||
'pages/product': '<html>{{> pages/partial}}</html>', | ||
'pages/partial': '<p>{{variable}}</p>', | ||
'pages/greet': '<h1>{{lang \'good\'}} {{lang \'morning\'}}</h1>', | ||
'pages/pre': '{{{pre object}}}', | ||
}, | ||
context = { | ||
variable: 'hello world', | ||
object: {} | ||
}; | ||
it('should use the assembler interface to load templates and translations', function(done) { | ||
@@ -24,0 +12,0 @@ var assembler = { |
@@ -111,3 +111,3 @@ var Code = require('code'); | ||
eval('var template = ' + precompiled); | ||
handlebars.partials[path] = handlebars.template(template); | ||
handlebars.partials[path] = handlebars.template(template); // eslint-disable-line no-undef | ||
} | ||
@@ -114,0 +114,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
150479
78
2435
8