@@ -17,7 +17,7 @@ CoffeeScript.run = (code, options = {}) ->
1717return unless window ?
1818
1919# Load a remote script from the current domain via XHR.
20- CoffeeScript .load = (url , callback ) ->
20+ CoffeeScript .load = (url , callback , options = {} ) ->
2121 xhr = if window .ActiveXObject
2222 new window.ActiveXObject (' Microsoft.XMLHTTP' )
2323 else
@@ -27,7 +27,7 @@ CoffeeScript.load = (url, callback) ->
2727 xhr .onreadystatechange = ->
2828 if xhr .readyState is 4
2929 if xhr .status in [0 , 200 ]
30- CoffeeScript .run xhr .responseText
30+ CoffeeScript .run xhr .responseText , options
3131 else
3232 throw new Error " Could not load #{ url} "
3333 callback () if callback
@@ -38,16 +38,19 @@ CoffeeScript.load = (url, callback) ->
3838# This happens on page load.
3939runScripts = ->
4040 scripts = document .getElementsByTagName ' script'
41- coffees = (s for s in scripts when s .type is ' text/coffeescript' )
41+ coffeetypes = [' text/coffeescript' , ' text/literate-coffeescript' ]
42+ coffees = (s for s in scripts when s .type in coffeetypes)
4243 index = 0
4344 length = coffees .length
4445 do execute = ->
4546 script = coffees[index++ ]
46- if script ? .type is ' text/coffeescript'
47+ mediatype = script ? .type
48+ if mediatype in coffeetypes
49+ options = {literate : mediatype is ' text/literate-coffeescript' }
4750 if script .src
48- CoffeeScript .load script .src , execute
51+ CoffeeScript .load script .src , execute, options
4952 else
50- CoffeeScript .run script .innerHTML
53+ CoffeeScript .run script .innerHTML , options
5154 execute ()
5255 null
5356
0 commit comments