Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 90 lines (61 sloc) 2.258 kb

Zappa is a CoffeeScript-optimized interface to Express and Socket.IO.


require('zappajs') ->

  # Server-side

  @get '/': ->
    @render 'index',
      title: 'Zappa!'
      scripts: '/zappa/Zappa.js /index.js /client.js'
      stylesheet: '/index.css'

  @view index:
    doctype 5
    html ->
      head ->
        title @title if @title
        for s in @scripts.split ' '
          script src: s
        link rel:'stylesheet', href:@stylesheet
      body ->
        h1 'Welcome to Zappa!'
        div id:'content'

  @css '/index.css':
      font: '12px Helvetica'
      color: 'pink'

  @get '/:name/data.json': ->
    record =
      id: 123
      email: "#{}"
    @send record

  @on 'ready': ->
    console.log "Client #{@id} is ready and says #{@data}."

  # Client-side

  @coffee '/index.js': ->
    alert 'hi'

  @client '/client.js': ->

    $ =>
      @emit 'ready', 'hello'

    @get '#/': ->
      @swap 'Ready to roll!'


npm install zappajs

This will install v0.3, which depends on Express 2.5. If you would rather use Express 3.0:

npm install zappajs@0.4

Learn More

Other resources

Build Status

Something went wrong with that request. Please try again.