summaryrefslogtreecommitdiff
path: root/lib/images.js
blob: 613a264ad69b9d7f185d269dc9f6951e47500bbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
var promises = require("./promises");
var htmlPaths = require("./html-paths");

exports.inline = function(func) {
    return function(element, html, messages, callback) {
        return promises.when(func(element)).then(function(result) {
            var attributes = {src: result.src};
            if (element.altText) {
                attributes.alt = element.altText;
            }
            html.selfClosing(htmlPaths.element("img", attributes));
        }).then(callback, callback);
    };
};