Skip to content

Instantly share code, notes, and snippets.

@eterps
Created Nov 1, 2010
Embed
What would you like to do?
Play with Coffeescript / Sinatra
Install node.js:
# See: http://nodejs.org/#download
NJSVERSION=v0.2.4
cd ~/tmp && wget http://nodejs.org/dist/node-${NJSVERSION}.tar.gz && tar zxf node-${NJSVERSION}.tar.gz && cd node-${NJSVERSION}
./configure --prefix=/opt/node-${NJSVERSION} && make && make install && ln -s /opt/node-${NJSVERSION} /opt/node
ln -s /opt/node/bin/node ~/bin/node
vi .bashrc
..
export PATH=$PATH:/opt/node/bin
..
Install npm:
# See: http://npmjs.org/
curl http://npmjs.org/install.sh | sh
Install coffeescript:
# See: http://jashkenas.github.com/coffee-script/
/opt/node/bin/npm install coffee-script
Create your coffeescript app with sinatra:
gem install sinatra haml coffee-script
mkdir views
vi app.rb
require 'sinatra'
require 'haml'
require 'coffee_script'
get('/') {haml :hello}
get('/js'){coffee :hello}
vi views/hello.coffee
alert 'Hello world!'
vi views/hello.haml
%html
%head
%script(type="application/javascript" src="/js")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment