handlebars-to-pdf
Advanced tools
Comparing version 1.0.0 to 1.0.1
38
index.js
//handlebars-to-pdf | ||
var Check = require('freeman-check'); | ||
var Handlebars = require('handlebars'); | ||
@@ -8,25 +7,24 @@ var PDF = require('html-pdf'); | ||
create: function(options, callback){ | ||
//check arguments have been supplied correctly. Required template_html and template_data, optional layout_settings | ||
var check_error = Check.test(options, { | ||
template_html: "string", | ||
template_data: "object" | ||
}, { | ||
layout_settings: { | ||
format: "string", | ||
orientation: "string", | ||
border: { | ||
top: "string", | ||
right: "string", | ||
bottom: "string", | ||
left: "string" | ||
} | ||
} | ||
}); | ||
//validate callback | ||
if(typeof callback !== "function"){ | ||
throw new Error("No callback function supplied."); | ||
return; | ||
} | ||
if(check_error instanceof Check.Error){ | ||
callback(check_error); | ||
//check options have been supplied correctly. Required template_html and template_data, optional layout_settings | ||
if(!options || typeof options !== "object"){ | ||
callback(new Error("`options` is malformatted or doesn't exist."), null); | ||
return; | ||
} | ||
if(!options.template_html || typeof options.template_html !== "string"){ | ||
callback(new Error("`options.template_html` is malformatted or doesn't exist."), null) | ||
return; | ||
} | ||
if(!options.template_data || typeof options.template_data !== "object"){ | ||
callback(new Error("`options.template_data` is malformatted or doesn't exist."), null) | ||
return; | ||
} | ||
var output_layout = options.layout_settings || { | ||
@@ -58,2 +56,2 @@ "format": "A4", | ||
} | ||
} | ||
} |
{ | ||
"name": "handlebars-to-pdf", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Turn a Handlebars template into a PDF. Receipts, contracts, statements etc. The choice is yours!", | ||
@@ -16,3 +16,2 @@ "main": "index.js", | ||
"dependencies": { | ||
"freeman-check": "^1.0.1", | ||
"handlebars": "^4.0.5", | ||
@@ -19,0 +18,0 @@ "html-pdf": "^2.0.1" |
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
2448
2
48
- Removedfreeman-check@^1.0.1
- Removedfreeman-check@1.1.0(transitive)