4. What is CoffeeScript ?
language designed to be compiled into JavaScript
piątek, 3 grudnia 2010
5. What is CoffeeScript ? - 2
language designed to be a compiled into JavaScript
code compiles one-to-one into the equivalent JS
piątek, 3 grudnia 2010
6. What is CoffeeScript ? - 3
language designed to be a compiled into JavaScript
code compiles one-to-one into the equivalent JS
syntax take advantages of modern OO languages
like Ruby, or Python
piątek, 3 grudnia 2010
7. What is CoffeeScript ? - 4
language designed to be a compiled into JavaScript
code compiles one-to-one into the equivalent JS
syntax take advantages of modern OO languages
like Ruby, or Python
cooperate with already existing JS libraries
(like jQuery, Facebook JS SDK, Google API etc.)
piątek, 3 grudnia 2010
8. What is CoffeeScript ? - 5
language designed to be a compiled into JavaScript
code compiles one-to-one into the equivalent JS
syntax take advantages of modern OO languages
like Ruby, or Python
cooperate with already existing JS libraries
(like jQuery, Facebook JS SDK, Google API etc.)
pass through JSLint without warnings =)
piątek, 3 grudnia 2010
9. How it can help us ?
less lines of code with better readability,
code easy to understand, and maintain
standard code encapsulation and variables
protection (no var anymore)
but...
piątek, 3 grudnia 2010
10. How it can help us ?
less lines of code with better readability,
code easy to understand, and maintains
standard code encapsulation and variables
protection (no var anymore)
but... even if you are writing code in CoffeeScript
you should know how JavaScript`s concepts work
piątek, 3 grudnia 2010
20. Using CoffeeScript
with Ruby on Rails
assumptions:
installed Node.js with packed manager npm
piątek, 3 grudnia 2010
21. Using CoffeeScript
with Ruby on Rails
assumptions:
installed Node.js with packed manager npm
installation CoffeeScript compiler
Gemfile
npm install coffee-script
piątek, 3 grudnia 2010
22. Using CoffeeScript
with Ruby on Rails
add gem Barista
Gemfile
gem 'barista', '>= 0.5.0'
piątek, 3 grudnia 2010
23. Using CoffeeScript
with Ruby on Rails
add gem Barista
Gemfile
gem 'barista', '>= 0.5.0'
run rake task
Console
rails generate barista:install
piątek, 3 grudnia 2010
24. Using CoffeeScript
with Ruby on Rails
add gem Barista
Gemfile
gem 'barista', '>= 0.5.0'
run rake task
Console
rails generate barista:install
create folder
app/
mkdir coffeescripts
piątek, 3 grudnia 2010
25. Using CoffeeScript
with Ruby on Rails
store scripts in /app/coffeescripts/
use *.coffee extension
run dev server (or trigger any request)
JS files are generated dynamically
you can preview those files in default JS folder
/public/javascripts/
piątek, 3 grudnia 2010
26. It`s nice, isn`t it ?
DEMO
&
discussion time
piątek, 3 grudnia 2010
27. Resources:
Official website of the project
http://jashkenas.github.com/coffee-script/
Github repo with source code
https://github.com/jashkenas/coffee-script
underscore.js implemented in CoffeeScript (nice example of good CS code)
http://jashkenas.github.com/coffee-script/documentation/docs/underscore.html
Barista gem website, and repo
https://github.com/Sutto/barista
piątek, 3 grudnia 2010