Skip to content

Instantly share code, notes, and snippets.

@danheberden
Created August 25, 2011 04:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danheberden/1169967 to your computer and use it in GitHub Desktop.
Save danheberden/1169967 to your computer and use it in GitHub Desktop.
coffeescript jsfiddle parser
(function(){
var s = "script",
n = "\n",
d = document,
tag = d.getElementsByTagName( s );
console.log( s,n,d,tag);
(function parseCoffee() {
console.log( 'running' );
// check for a non-src'd script
var found = false;
for ( var i = 0; i < tag.length; i++ ) {
if ( !tag[i].src ) {
found = i;
console.log( 'found!', i, tag[i] );
}
}
if ( found === false ) {
setTimeout( parseCoffee, 50 );
} else {
var b = tag[found].innerHTML.split(n);
d.write('<'+s+' type="text/coffeescript">'+b.slice(2,b.length-2).join(n)+'</'+s+'>');
}
})();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment