# Exoskeleton

This gem builds out the basic framework to use [Backbone.js](http://backbonejs.org/) along with templating abilities

## Installation

Add this line to your application's Gemfile:

    gem 'exoskeleton'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install exoskeleton

## Usage

This setup is going through the process when building a brand new rails application. 
Note: YOUR_APP_NAME is not a specific name, it just needs to be the same throughout.

Add the following to `application.rb`:

    config.exoskeleton_base = 'YOUR_APP_NAME'

Add the following to `application.js` before `//= require_tree .`:

    //= require exoskeleton
    //= require ./YOUR_APP_NAME
    //= require_tree ./backbone/views
    //= require_tree ./backbone/templates
    
Then build the folder structure to hold all of your awesome Backbone. We use the following structure that can be built easily using the [backbone-rails](https://github.com/codebrew/backbone-rails) gem

    app/assets/javascripts/backbone/views
    app/assets/javascripts/backbone/models
    app/assets/javascripts/backbone/collections
    app/assets/javascripts/backbone/templates
    
Create base javascript file `app/assets/javascripts/YOUR_APP_NAME.js` with the following content:
    
    YOUR_APP_NAME = {
      views:{}
    }
    
    $(function(){
      var hello_view = new YOUR_APP_NAME.views.hello()
      $('body').append(hello_view.render().el)
    })
    
Create your first view `app/assets/javascripts/backbone/views/hello.js` with the following content:
    
    YOUR_APP_NAME.views.hello = exoskeleton.views.base_view.extend({

      render: function(){
    
        this.$el.html(YOUR_APP_NAME.templates['hello'])
    
        return this
      }
    
    })
    
Create your first template `app/assets/javascripts/templates/hello.jst.ejs.haml` with the following content:
    
    %h1
      Hello from new view through exoskeleton!

Generate a new view to show off the awesomness
    
    bundle exec rails g controller home index
    
Start up your server

    rails s
    
Navigate to the awesomness

    http://localhost:3000/home/index

    

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request