Skip to content

Instantly share code, notes, and snippets.

@tadatuta
Created November 30, 2014 00:57
Show Gist options
  • Save tadatuta/11c9a529df64dd635510 to your computer and use it in GitHub Desktop.
Save tadatuta/11c9a529df64dd635510 to your computer and use it in GitHub Desktop.
Replace comments with iframes in enb-bem-docs results
(function(d) {
var body = d.body,
content = body.childNodes,
length = content.length;
function replaceComment(node) {
if(node.nodeType != 8) return;
var src = 'http://localhost:8080/' + node.data.replace(' bem-example: ', '').replace(' ', ''),
bundleName = src.split('/').pop(),
iframe = d.createElement('iframe');
iframe.src = src + '/' + bundleName + '.html';
body.replaceChild(iframe, node);
}
for(var i = 0; i < length; i++) {
replaceComment(content[i]);
}
})(document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment