removing CoffeeScript.activate() simply including the tag will do for text/coffeescript

This commit is contained in:
Jeremy Ashkenas 2010-02-24 23:57:39 -05:00
parent 23c5ebb00f
commit 22674bc536
6 changed files with 20 additions and 35 deletions

View File

@ -923,9 +923,6 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre>
</div>
<script src="extras/coffee-script.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/coffeescript">
window.repl_compile: ->
@ -959,9 +956,8 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre>
$(document.body).click -> close_menus()
</script>
<script>
CoffeeScript.activate();
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="extras/coffee-script.js"></script>
</body>
</html>

View File

@ -1,10 +1,9 @@
EXTRAS:
"extras/coffee-script.js" is a concatenated and compressed version of the
CoffeeScript compiler. To use it in the browser, include the script, and call:
CoffeeScript.activate();
After any inline script tags of type "text/coffeescript" on the page.
CoffeeScript compiler. To use it in the browser, include the script after any
inline script tags of type "text/coffeescript" on the page. It will compile
and evaluate all of the scripts in order.
This folder also includes rough cuts of CoffeeScript syntax highlighters for

File diff suppressed because one or more lines are too long

View File

@ -1803,9 +1803,6 @@ task(<span class="String"><span class="String">'</span>test<span class="String">
</div>
<script src="extras/coffee-script.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/coffeescript">
window.repl_compile: ->
@ -1839,9 +1836,8 @@ task(<span class="String"><span class="String">'</span>test<span class="String">
$(document.body).click -> close_menus()
</script>
<script>
CoffeeScript.activate();
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="extras/coffee-script.js"></script>
</body>
</html>

View File

@ -1,5 +1,5 @@
(function(){
var lexer, parser, path;
var _a, _b, lexer, parser, path, tag;
// Set up for both the browser and the server.
if ((typeof process !== "undefined" && process !== null)) {
process.mixin(require('nodes'));
@ -47,16 +47,11 @@
};
// Activate CoffeeScript in the browser by having it compile and eval
// all script tags with a content-type of text/coffeescript.
exports.activate = function activate() {
var _a, _b, _c, script, scripts;
scripts = document.getElementsByTagName('script');
_a = []; _b = scripts;
for (_c = 0; _c < _b.length; _c++) {
script = _b[_c];
if (script.type === 'text/coffeescript') {
_a.push(eval(exports.compile(script.innerHTML)));
}
if ((typeof document !== "undefined" && document !== null) && document.getElementsByTagName) {
_a = document.getElementsByTagName('script');
for (_b = 0; _b < _a.length; _b++) {
tag = _a[_b];
tag.type === 'text/coffeescript' ? eval(exports.compile(tag.innerHTML)) : null;
}
return _a;
};
}
})();

View File

@ -40,7 +40,6 @@ exports.tree: (code) ->
# Activate CoffeeScript in the browser by having it compile and eval
# all script tags with a content-type of text/coffeescript.
exports.activate: ->
scripts: document.getElementsByTagName 'script'
for script in scripts when script.type is 'text/coffeescript'
eval exports.compile script.innerHTML
if document? and document.getElementsByTagName
for tag in document.getElementsByTagName('script') when tag.type is 'text/coffeescript'
eval exports.compile tag.innerHTML