In Ember, the application's state manager handles routing. Let's take a look at a simple example:
App.stateManager = Ember.StateManager.create({
start: Ember.State.extend({
index: Ember.State.extend({
route: "/",| # config/initializers/source_maps.rb | |
| if Rails.env.development? | |
| require 'open3' | |
| module CoffeeScript | |
| class SourceMapError < StandardError; end; | |
| class << self | |
| def map_dir |
| import SimpleHTTPServer | |
| class CORSHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
| def send_head(self): | |
| """Common code for GET and HEAD commands. | |
| This sends the response code and MIME headers. | |
| Return value is either a file object (which has to be copied | |
| to the outputfile by the caller unless the command was HEAD, | |
| and must be closed by the caller under all circumstances), or |
| class ActionDispatch::Routing::Mapper | |
| def draw(routes_name) | |
| instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb"))) | |
| end | |
| end | |
| BCX::Application.routes.draw do | |
| draw :api | |
| draw :account | |
| draw :session |
| #!/usr/bin/env sh | |
| ## | |
| # This is script with usefull tips taken from: | |
| # https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
| # | |
| # install it: | |
| # curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
| # |
Created by Christopher Manning
| <script type="text/x-handlebars" data-template-name="list-view"> | |
| <ul> | |
| {{#each posts}} | |
| {{#view MyApp.PostView contentBinding="this"}} | |
| {{#with content}} | |
| <li class="post"> | |
| <a href="#"> | |
| <img data-id="{{unbound id}}" src="{{unbound embed_url}}"> | |
| <span class="meta">{{unbound short_text}}</span> | |
| </a> |
| var State = Ember.State.extend({}); | |
| var ViewState = Ember.ViewState.extend({}); | |
| // existing | |
| App.statechart = Ember.StateManager.create({ | |
| loggedOut: ViewState.create({}), | |
| loggingIn: ViewState.create({}), | |
| loggedIn: Ember.StateManager.create({ | |
| appLoadFailed: ViewState.create({}), | |
| appLoading: ViewState.create({}), |
| require 'sproutcore' | |
| require 'sproutcore-statechart' | |
| require 'sproutcore-routing' | |
| App = SC.Application.create() | |
| App.GlobalNavController = SC.Object.create( | |
| home: -> App.statechart.gotoState 'home' | |
| about: -> App.statechart.gotoState 'about' | |
| ) |