From 1d473cf407f54a03ac248c01c5214e3444f87be3 Mon Sep 17 00:00:00 2001 From: Geoff Kimball Date: Wed, 10 Feb 2016 16:22:47 -0800 Subject: [PATCH] Remove unnecessary parameters from componentFactory and makeColumn functions --- lib/componentFactory.js | 13 ++++++------- lib/inky.js | 3 +-- lib/makeColumn.js | 4 ++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/componentFactory.js b/lib/componentFactory.js index c5aa66d..1145173 100644 --- a/lib/componentFactory.js +++ b/lib/componentFactory.js @@ -1,15 +1,14 @@ var format = require('util').format; +var $ = require('cheerio'); /** * Returns output for desired custom element - * @param {object} $ - Instance of Cheerio. * @param {object} element - Element as a Cheerio object. - * @param {string} type - Element type. * @returns {string} HTML converted from a custom element to table syntax. */ -module.exports = function($, element) { - var component = $(element), - inner = $(element).html(); +module.exports = function(element) { + var component = $(element); + var inner = $(element).html(); switch (element.name) { case this.components.callout: @@ -40,7 +39,7 @@ module.exports = function($, element) { return format('
%s
', classes.join(' '), inner); case this.components.subcolumns: - return this.makeColumn($, component, 'subcolumns'); + return this.makeColumn(component, 'subcolumns'); case this.components.container: var classes = ['container']; @@ -51,7 +50,7 @@ module.exports = function($, element) { return format('
%s
', classes.join(' '), inner); case this.components.columns: - return this.makeColumn($, component, 'columns'); + return this.makeColumn(component, 'columns'); case this.components.row: var classes = ['row']; diff --git a/lib/inky.js b/lib/inky.js index 188fc83..cadb00a 100644 --- a/lib/inky.js +++ b/lib/inky.js @@ -1,4 +1,3 @@ -var cheerio = require('cheerio'); var extend = require('util')._extend; var format = require('util').format; var values = require('object-values'); @@ -173,7 +172,7 @@ Inky.prototype.scaffoldElements = function($, str) { // Replace tags with proper table syntax // elMarkup retains the inner html within the markup if (element !== undefined) { - elMarkup = this.componentFactory($, element); + elMarkup = this.componentFactory(element); $(element).replaceWith(elMarkup); } else { diff --git a/lib/makeColumn.js b/lib/makeColumn.js index 365fb2d..ee5bb59 100644 --- a/lib/makeColumn.js +++ b/lib/makeColumn.js @@ -1,13 +1,13 @@ var format = require('util').format; +var $ = require('cheerio'); /** * Returns output for column elements. * @todo This could be refactored to handle both cols and subcols. - * @param {object} $ - Instance of Cheerio. * @param {string} col - Column to format. * @param {string} type - Type of column. */ -module.exports = function($, col, type) { +module.exports = function(col, type) { var output = ''; var inner = $(col).html(); var classes = [];