O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CoffeeScript Programming with jQuery, Rails, and Node.js

Book Description

Get more fun and productivity out of your web development by learning CoffeeScript. This book is the perfect primer that takes you from language basics to creating responsive applications. Enjoy.

  • Learn CoffeeScript, a small and elegant language that compiles to JavaScript and will make your life as a web developer better
  • Explore the syntax of the language and see how it improves and enhances JavaScript
  • Build three example applications in CoffeeScript step by step

In Detail

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.

"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.

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.

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.

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.

Table of Contents

  1. CoffeeScript Programming with jQuery, Rails, and Node.js
    1. Table of Contents
    2. CoffeeScript Programming with jQuery, Rails, and Node.js
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
      2. Why Subscribe?
        1. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Why CoffeeScript?
      1. CoffeeScript syntax
        1. Semicolons and braces
        2. Whitespace
        3. Parenthesis
      2. CoffeeScript has great function syntax
        1. Return isn't required
        2. Function arguments
        3. Where did the var keyword go?
      3. CoffeeScript handles scope better
        1. Top level var keywords
      4. CoffeeScript has better object syntax
        1. Inheritance
        2. Overwhelmed?
        3. Extending prototypes
      5. A few other things CoffeeScript fixes
        1. Reserved words and object syntax
        2. String concatenation
        3. Equality
        4. The existential operator
      6. List comprehensions
        1. The while loop
      7. Conditional clauses and logical aliases
      8. Array slicing and splicing
      9. Destructuring or pattern matching
      10. => and @
      11. Switch statements
      12. Chained comparisons
      13. Block strings, block comments, and strings
      14. Summary
    9. 2. Running CoffeeScript
      1. The CoffeeScript stack
      2. Node.js and npm
      3. Node.js, npm, and CoffeeScript on Windows
      4. Installing CoffeeScript on a Mac
        1. Using the Apple installer
        2. Using Homebrew
        3. Installing CoffeeScript with npm
      5. Installing CoffeeScript on Linux
        1. Ubuntu and MintOS
        2. Debian
        3. Other distributions
        4. Installing CoffeeScript with npm
      6. Building Node.js from source
        1. Building on Linux or Unix
        2. Building on Windows
      7. Using CoffeeScript
      8. The coffee command
        1. The REPL
        2. Running .coffee files
        3. Compiling to JavaScript
        4. Watching
        5. Putting it all together
      9. Summary
    10. 3. CoffeeScript and jQuery
      1. Finding and changing elements
        1. The $ function
      2. Utility functions
      3. Ajax methods
      4. Using jQuery
      5. Using CoffeeScript and jQuery in the browser
        1. Compiling CoffeeScript
        2. jQuery and CoffeeScript
        3. Testing it all
        4. Running a local web server
      6. Our application
        1. TodoMVC
        2. Our initial HTML
        3. Initializing our app
        4. Adding a to-do item
          1. Using localStorage
        5. Displaying the to-do items
        6. Showing the to-do items
        7. Removing and completing items
        8. Now, it's your turn!
      7. Summary
    11. 4. CoffeeScript and Rails
      1. What makes Rails special?
        1. Convention over configuration
        2. Don't repeat yourself (DRY)
      2. Rails and JavaScript
      3. Rails and CoffeeScript
      4. Installing Rails
        1. Installing Rails using RailsInstaller
        2. Installing Rails using RVM
        3. Got Rails installed?
      5. Developing our Rails application
        1. MVC
        2. Running our application
        3. Our todo_items resource
        4. routes.rb
        5. The controller
        6. The view
        7. The CSS
        8. Our model
        9. Migrations
        10. The Rails console
        11. Displaying the items in our view using ERB
        12. Creating a partial
        13. Adding new items
        14. Let's try and add a to-do item
        15. Adding a CoffeeScript view
        16. CoffeeScript in the asset pipeline
        17. Completing the to-do items
        18. Removing tasks
        19. Now, it's your turn
      6. Summary
    12. 5. CoffeeScript and Node.js
      1. Node is event-driven
      2. Node is fast and scalable
      3. Node is not Rails
      4. Node and CoffeeScript
      5. "Hello World" in Node
      6. Express
      7. WebSocket
      8. Jade
      9. Our application
      10. Let's get started
        1. package.json
        2. Installing our modules
        3. Creating our app
        4. Running our application
      11. Creating a view
      12. node-supervisor
      13. The to-do list view
        1. Middleware
        2. Our stylesheet
      14. The client side
      15. Adding collaboration
      16. Creating the collaboration UI
      17. WebSocket on the client
      18. WebSocket on the server
      19. Joining a list
        1. The UI
        2. Leaving a list
        3. Testing it all
      20. Adding to-do items to a shared list
      21. Removing to-do items from a shared list
        1. Now, it's your turn
      22. Summary
    13. Index