Skip to content

Instantly share code, notes, and snippets.

@mhawksey
Created October 23, 2017 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhawksey/8d3e5dd8b05b6d70e5e099b09883e831 to your computer and use it in GitHub Desktop.
Save mhawksey/8d3e5dd8b05b6d70e5e099b09883e831 to your computer and use it in GitHub Desktop.
Apps Script exerpt to include images in HTML Service
/**
* given an image object, it will generate an img tag
* @param {Object} imgData with image data
* @return {string} of img tag or src
*/
ns.img = function (imgData, isImgTag) {
if (!isImgTag){
var html = '<img ';
Object.entries(imgData).forEach(function(k){ html += k[0]+'="'+k[1]+'" '});
html += '>\n'
return html
} else {
return imgData.src;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment