Skip to content

Commit

Permalink
Remove unnecessary parameters from componentFactory and makeColumn fu…
Browse files Browse the repository at this point in the history
…nctions
  • Loading branch information
gakimball committed Feb 11, 2016
1 parent d753610 commit 1d473cf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
13 changes: 6 additions & 7 deletions lib/componentFactory.js
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -40,7 +39,7 @@ module.exports = function($, element) {
return format('<table class="%s"><tr><td><table><tr><td>%s</td></tr></table></td></tr></table>', classes.join(' '), inner);

case this.components.subcolumns:
return this.makeColumn($, component, 'subcolumns');
return this.makeColumn(component, 'subcolumns');

case this.components.container:
var classes = ['container'];
Expand All @@ -51,7 +50,7 @@ module.exports = function($, element) {
return format('<table class="%s"><tbody><tr><td>%s</td></tr></tbody></table>', classes.join(' '), inner);

case this.components.columns:
return this.makeColumn($, component, 'columns');
return this.makeColumn(component, 'columns');

case this.components.row:
var classes = ['row'];
Expand Down
3 changes: 1 addition & 2 deletions lib/inky.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var cheerio = require('cheerio');
var extend = require('util')._extend;
var format = require('util').format;
var values = require('object-values');
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions lib/makeColumn.js
Original file line number Diff line number Diff line change
@@ -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 = [];
Expand Down

0 comments on commit 1d473cf

Please sign in to comment.