Skip to content

Instantly share code, notes, and snippets.

@pneff
Forked from slezica/tumblr-gist.js
Created July 10, 2012 13:40
Show Gist options
  • Save pneff/3083302 to your computer and use it in GitHub Desktop.
Save pneff/3083302 to your computer and use it in GitHub Desktop.
tumblr gist embedder
var real_docwrite = document.write,
body = $('body');
(function insertGists(tags) {
var $tag;
if (tags.length > 0) {
tag = tags.shift();
$tag = $(tag);
document.write = function(stylesheet) {
$('head').append(stylesheet);
document.write = function(gist) {
$tag.replaceWith(gist)
insertGists(tags);
}
}
body.append('<scr' + 'ipt src="' + $tag.data('gist') + '"></scr' + 'ipt>');
} else {
document.write = real_docwrite;
}
})($('[data-gist]').get());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment