summaryrefslogtreecommitdiff
path: root/lib/images.js
blob: d7c2ebced598c4353bdc76baf13471dec0c2548c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var promises = require("./promises");
var Html = require("./html");

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