improving CoffeeScript in browser script activation, and updating docs

This commit is contained in:
Jeremy Ashkenas
2010-02-25 06:26:27 -05:00
parent 66a6568fe7
commit b32a60585b
5 changed files with 33 additions and 99 deletions

View File

@@ -41,5 +41,10 @@ exports.tree: (code) ->
# Activate CoffeeScript in the browser by having it compile and eval
# all script tags with a content-type of text/coffeescript.
if document? and document.getElementsByTagName
for tag in document.getElementsByTagName('script') when tag.type is 'text/coffeescript'
eval exports.compile tag.innerHTML
process_scripts: ->
for tag in document.getElementsByTagName('script') when tag.type is 'text/coffeescript'
eval exports.compile tag.innerHTML
if window.addEventListener
window.addEventListener 'load', process_scripts, false
else if window.attachEvent
window.attachEvent 'onload', process_scripts