Currently working through this tutorial on using Backbone.js with coffeescript.
Leveraging the following index.html
file:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CoffeeScript, Meet Backbone.js: Part N</title>
<link rel="stylesheet" href="style.css">
<script src=".6.1/jquery.min.js"></script>
<script src=".js"></script>
<script src=".js/1.1.6/underscore-min.js"></script>
<script src=".js/0.3.3/backbone-min.js"></script>
<script type="text/javascript" src="./index.js"></script>
</head>
<body>
<header>
<h1>CoffeeScript, Meet Backbone.js: Part 1</h1>
</header>
</body>
</html>
which loads an index.js
file after loading Backbone, jQuery, etc from a cdn. Hoping to work within a script.coffee
file that I'd like to have automatically pile into the script.js
file loaded by index.html
above by running something like coffee script.coffee -c -w.
Trouble is, I'm getting ReferenceError
s when I try to run the above mand on the following script.coffee
file:
jQuery ->
class ListView extends Backbone.View
el: $ 'body'
initialize: ->
_.bindAll @
@render()
render: ->
$(@el).append '<ul><li>Hello, Backbone!</li></ul>'
list_view = new ListView
For instance:
ReferenceError: jQuery is not defined
...
because, clearly, jQuery is being loaded in the index.html
file.
Is there a way to suppress the error reporting from the coffeescript piler so that it just converts the code without the error?
Currently working through this tutorial on using Backbone.js with coffeescript.
Leveraging the following index.html
file:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CoffeeScript, Meet Backbone.js: Part N</title>
<link rel="stylesheet" href="style.css">
<script src="https://ajax.googleapis./ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script src="http://ajax.cdnjs./ajax/libs/json2/20110223/json2.js"></script>
<script src="http://ajax.cdnjs./ajax/libs/underscore.js/1.1.6/underscore-min.js"></script>
<script src="http://ajax.cdnjs./ajax/libs/backbone.js/0.3.3/backbone-min.js"></script>
<script type="text/javascript" src="./index.js"></script>
</head>
<body>
<header>
<h1>CoffeeScript, Meet Backbone.js: Part 1</h1>
</header>
</body>
</html>
which loads an index.js
file after loading Backbone, jQuery, etc from a cdn. Hoping to work within a script.coffee
file that I'd like to have automatically pile into the script.js
file loaded by index.html
above by running something like coffee script.coffee -c -w.
Trouble is, I'm getting ReferenceError
s when I try to run the above mand on the following script.coffee
file:
jQuery ->
class ListView extends Backbone.View
el: $ 'body'
initialize: ->
_.bindAll @
@render()
render: ->
$(@el).append '<ul><li>Hello, Backbone!</li></ul>'
list_view = new ListView
For instance:
ReferenceError: jQuery is not defined
...
because, clearly, jQuery is being loaded in the index.html
file.
Is there a way to suppress the error reporting from the coffeescript piler so that it just converts the code without the error?
Share Improve this question edited Nov 30, 2013 at 4:40 fox asked Nov 30, 2013 at 4:18 foxfox 16.6k22 gold badges59 silver badges85 bronze badges1 Answer
Reset to default 10The options must go before the file, e.g.:
coffee -cw script.coffee
Otherwise, it will try to run script.coffee
right then and there as a Node.js script, passing it the options -c
and -w
. That's not what you want; if you want the CoffeeScript piler to get the options, it's got to be before the file name.