From a9e35203c242d082b77538f83373e08a2308340e Mon Sep 17 00:00:00 2001 From: hacksalot Date: Tue, 30 Jan 2018 12:40:17 -0500 Subject: [PATCH] [style] Tighten syntax in html-pdf-cli-generator.coffee|js. --- dist/generators/html-pdf-cli-generator.js | 14 +++++++------- src/generators/html-pdf-cli-generator.coffee | 11 ++++------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/dist/generators/html-pdf-cli-generator.js b/dist/generators/html-pdf-cli-generator.js index eb4692e..54cf3b5 100644 --- a/dist/generators/html-pdf-cli-generator.js +++ b/dist/generators/html-pdf-cli-generator.js @@ -87,18 +87,18 @@ Definition of the HtmlPdfCLIGenerator class. TODO: Local web server to ease wkhtmltopdf rendering */ wkhtmltopdf: function(markup, fOut, opts, on_error) { - var tempFile, wkhtmltopdf_args, wkhtmltopdf_options; + var tempFile, wkargs, wkopts; tempFile = fOut.replace(/\.pdf$/i, '.pdf.html'); FS.writeFileSync(tempFile, markup, 'utf8'); - wkhtmltopdf_options = _.extend({ - 'margin-bottom': '10mm', - 'margin-top': '10mm' + wkopts = _.extend({ + 'margin-top': '10mm', + 'margin-bottom': '10mm' }, opts.wkhtmltopdf); - wkhtmltopdf_options = _.flatten(_.map(wkhtmltopdf_options, function(v, k) { + wkopts = _.flatten(_.map(wkopts, function(v, k) { return ['--' + k, v]; })); - wkhtmltopdf_args = wkhtmltopdf_options.concat([tempFile, fOut]); - SPAWN('wkhtmltopdf', wkhtmltopdf_args, false, on_error, this); + wkargs = wkopts.concat([tempFile, fOut]); + SPAWN('wkhtmltopdf', wkargs, false, on_error, this); }, /** diff --git a/src/generators/html-pdf-cli-generator.coffee b/src/generators/html-pdf-cli-generator.coffee index 15a7edd..f7682c8 100644 --- a/src/generators/html-pdf-cli-generator.coffee +++ b/src/generators/html-pdf-cli-generator.coffee @@ -70,14 +70,11 @@ engines = FS.writeFileSync tempFile, markup, 'utf8' # Prepare wkhtmltopdf arguments. - wkhtmltopdf_options = _.extend( - {'margin-bottom': '10mm', 'margin-top': '10mm'}, opts.wkhtmltopdf) - wkhtmltopdf_options = _.flatten(_.map(wkhtmltopdf_options, (v, k)-> - return ['--' + k, v] - )) - wkhtmltopdf_args = wkhtmltopdf_options.concat [ tempFile, fOut ] + wkopts = _.extend 'margin-top': '10mm', 'margin-bottom': '10mm', opts.wkhtmltopdf + wkopts = _.flatten _.map wkopts, (v, k) -> ['--' + k, v] + wkargs = wkopts.concat [ tempFile, fOut ] - SPAWN 'wkhtmltopdf', wkhtmltopdf_args , false, on_error, @ + SPAWN 'wkhtmltopdf', wkargs , false, on_error, @ return