Skip to content

Commit

Permalink
cleanup angularjs demo
Browse files Browse the repository at this point in the history
  • Loading branch information
rubys committed Dec 13, 2013
1 parent ec0f50b commit af22c92
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
31 changes: 9 additions & 22 deletions demo/angularjs.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
# based on http://docs.angularjs.org/tutorial

require 'wunderbar/sinatra'
require 'wunderbar/angular/route'
require 'wunderbar/angular/resource'
require 'wunderbar/angularjs/route'
require 'wunderbar/angularjs/resource'

set :views, File.dirname(__FILE__)

get '/' do
_html :index
_html :'views/index'
end

# allow path to override 'views'
helpers do
def find_template(view, name, engine, &block)
view = Sinatra::Application.root unless File.dirname(name.to_s) == '.'
super(view, name, engine, &block)
get '/partials/:_name.html' do
_html :"partials/#{params[:_name]}"
end
end

# define routes to everything in the partials directory
Dir['partials/*'].each do |partial|
partial = partial.chomp(File.extname(partial))
get "/#{partial}.html" do
_html partial.to_sym
end
get '/js/:_name.js' do
_js :"js/#{params[:_name]}"
end

# define routes to everything in the js directory
Dir['js/*'].each do |js|
js = js.chomp(File.extname(js))
get "/#{js}.js" do
_js js.to_sym
end
end
6 changes: 2 additions & 4 deletions docs/AngularJS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ AngularJS
This demo is an implementation of the
[AngularJS Tutorial](http://docs.angularjs.org/tutorial) through step 11.

It is customary to place all views in a `views` directory in Sinatra; it is
customary to split views out by type in AngularJS. Doing this requires one
to override the `find_template` helper. This demo does that, and the
result is
This demo starts by defining one index, and where to find the partials and
js templates:
[angularjs.rb](https://github.com/rubys/wunderbar/blob/master/demo/angularjs.rb).

views
Expand Down

0 comments on commit af22c92

Please sign in to comment.