mirror of
https://github.com/KevinMidboe/inline-html.git
synced 2025-12-08 20:29:06 +00:00
Added support for html being a string or filename. Added tests. Updated dependencies. Updated docs.
This commit is contained in:
17
lib/index.js
17
lib/index.js
@@ -6,12 +6,25 @@ var inlineStyle = require('./inline-style');
|
||||
var inlineImg = require('./inline-img');
|
||||
var inlineLinkLess = require('./inline-link-less');
|
||||
|
||||
var inline = co.wrap(function * (filename, options) {
|
||||
var inline = co.wrap(function * (html, options) {
|
||||
options = _.defaults(options || {}, {
|
||||
filename: null,
|
||||
less: {},
|
||||
verbose: false
|
||||
});
|
||||
var html = yield fs.readFile(filename, 'utf8');
|
||||
var filename;
|
||||
try {
|
||||
filename = html;
|
||||
html = yield fs.readFile(filename, 'utf8');
|
||||
}
|
||||
catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
filename = options.filename;
|
||||
}
|
||||
else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
var files = [filename];
|
||||
|
||||
// Inline links
|
||||
|
||||
Reference in New Issue
Block a user