lib/templates/lib/app.rb.eruby in skellington-0.4.0 vs lib/templates/lib/app.rb.eruby in skellington-0.4.1

- old
+ new

@@ -1,12 +1,32 @@ require 'sinatra/base' +require 'tilt/erubis' -class <%= @gen.camelname %> < Sinatra::Base - get '/' do - @content = '<h1>Hello from <%= @gen.camelname %></h1>' - @title = '<%= @gen.camelname %>' - erb :index, layout: :default - end +require_relative '<%= @gen.wormname %>/racks' +require_relative '<%= @gen.wormname %>/helpers' - # start the server if ruby file executed directly - run! if app_file == $0 +module <%= @gen.camelname %> + class App < Sinatra::Base + helpers do + include <%= @gen.camelname %>::Helpers + end + + get '/' do + respond_to do |wants| + wants.html do + @content = '<h1>Hello from <%= @gen.camelname %></h1>' + @title = '<%= @gen.camelname %>' + erb :index, layout: :default + end + + wants.json do + { + app: '<%= @gen.camelname %>' + }.to_json + end + end + end + + # start the server if ruby file executed directly + run! if app_file == $0 + end end