Skip to content

Instantly share code, notes, and snippets.

@pjkelly
Created December 12, 2012 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjkelly/4263740 to your computer and use it in GitHub Desktop.
Save pjkelly/4263740 to your computer and use it in GitHub Desktop.
window.AppName =
Models: {}
Colls: {}
Views: {}
Routers: {}
Data: {}
Pages:
Home:
init: ->
new AppName.Views.HomePage el: $("body")
About:
init: ->
new AppName.Views.AboutPage el: $("body")
initialize: (page) ->
# call any initial setup code
# initialize the page view component
@.Pages[page].init()
<!doctype html>
...
<body>
<%= yield %>
...
<%= javascript_include_tag("application") %>
<%= yield :javascripts %>
<% if jspage? %>
<!-- initialize the application -->
<%= javascript_tag do -%>
OTG.initialize("<%= jspage %>");
<% end -%>
<% end %>
</body>
</html>
class ApplicationController < ActionController::Base
before_filter :set_jspage
helper_method :jspage, :jspage?
protected
def jspage_data
@jspage_data ||= YAML.load_file(File.join("jspages.yml"))
end
def set_jspage
@jspage = jspage_data[[controller_name, action_name].join('-')]
end
def jspage
@jspage
end
def jspage?
@jspage.present?
end
end
class HomeController < ApplicationController
def index
end
end
home-index: Home
pages-about: About
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment