Book Image

CoffeeScript Programming with jQuery, Rails, and Node.js

By : Michael Erasmus
Book Image

CoffeeScript Programming with jQuery, Rails, and Node.js

By: Michael Erasmus

Overview of this book

<p>CoffeeScript is a young but popular language that makes web programming fun and more productive. It compiles to JavaScript and unleashes its powerful features while not straying too far from the language. It’s become one of the most popular languages on Github and is being used for both browser and server side programming.<br /><br />"CoffeeScript programming with jQuery, Rails, and Node.js" will not only teach you the CoffeeScript language but also show you how it’s being used by professional programmers with the latest web technologies.<br /><br />This book will teach you the basics of the language, focusing particularly on how it improves on JavaScript. It then focuses on building real life projects in CoffeeScript using jQuery, Rails, and Node.js. <br /><br />We look at CoffeeScript as a language that takes the power of JavaScript and presents it in an elegant and concise syntax. We will then see how we can use its power to write beautiful and short programs for various environments and how it complements the latest and greatest web frameworks.<br /><br />CoffeeScript programming with jQuery, Rails, and Node.js is all you need to become well versed with this great language and set you on your way to using it to write web applications.</p>
Table of Contents (12 chapters)
CoffeeScript Programming with jQuery, Rails, and Node.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using CoffeeScript and jQuery in the browser


Before we can start playing with jQuery and CoffeeScript, let's talk about how you go about writing CoffeeScript code that runs in the browser.

Compiling CoffeeScript

The most common way of compiling CoffeeScript for a web application is to run the coffee command to watch one or more CoffeeScript files for changes and then to compile them to JavaScript. The output will then be included in your web application.

As an example, we'll organize our project folder structure to look something like the following folder structure:

'

The src folder is where your CoffeeScript files would go. We could then start a CoffeeScript compiler to watch that folder and compile the JavaScript to our public/js folder.

This is what the CoffeeScript command would look like:

coffee -co public/js -w src/

Keep this command running in the background in its own terminal window and it will recompile your CoffeeScript files when you save them.

Tip

CoffeeScript tags

Another way of running...