Rail

A light framework for front-end development inspired by Rails. It is solely based on Sprockets and includes the following components out of the box:
- CoffeeScript for JavaScript,
- Haml for HTML,
- Sass for CSS, and
- Uglifier for compression.
Installation
First of all, include the gem in your Gemfile. Here is an example:
source 'https://rubygems.org'
gem 'rail', '~> 0.0.4'
# The rest is optional
gem 'redcarpet', '~> 3.1.2' # your favorit complement to Haml
gem 'thin', '~> 1.6.2' # your favorit Web server
Then run Bundler:
$ bundle
Now we need to create three files: config/application.rb, config.ru, and
Rakefile. In config/application.rb:
require 'bundler'
Bundler.require(:default)
module MyProject
class Application < Rail::Application
end
end
In config.ru:
require_relative 'config/application'
run MyProject::Application.new
In Rakefile:
require_relative 'config/application'
MyProject::Application.load_tasks
Feel free to replace MyProject with the name of your project. That’s it.
Usage
Rail closely follows Rails. If you know Rails, you already know Rail.
Structure
Organize your code according to the following convention:
app/assets/javascriptsfor scripts,app/assets/stylesheetsfor styles,app/viewsfor templates,app/helpersfor helper modules, andpublicfor other static content.
In addition, app/views/layouts/application.html.haml will be used for
rendering the root of your application (both / and /index.html).
Configuration
As with Rails, Rail is configured inside config/application.rb:
module MyProject
class Application < Rail::Application
# Import assets from other gems:
config.gems << 'turbolinks'
# Precompile assets using `rake assets`:
config.precompile << 'application.css'
config.precompile << 'application.js'
config.precompile << 'index.html'
# Compress assets:
config.compress = true
end
end
If config.compress is not specified, it is implicitly set to
ENV['RAIL_ENV'] == 'production'.
Commands
Run Rake to see the available tasks:
$ rake -T
rake assets # Precompile assets
rake server # Start server
rake server starts up a Web server; if none is specified in Gemfile,
WEBrick
will be fired up.
rake assets compiles your assets and stores them in public. You should
explicitly tell Rail what to compile as it was shown in the previous section.
Note that the server will try to serve from public first, so make sure you
delete the precompiled files when you change your code in app.
Examples
Additional usage examples can be found here, here, and here.