Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
require 'sinatra/base'
module Sinatra
module JavaScripts
def js *scripts
@js ||= []
@js = scripts
end
def javascripts(*args)
js = []
js << settings.javascripts if settings.respond_to?('javascripts')
js << args
js << @js if @js
js.flatten.uniq.map do |script|
"<script src=\"#{path_to script}\"></script>"
end.join
end
def path_to script
case script
when :jquery then 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'
when :rightjs then 'http://cdn.rightjs.org/right-2.3.0.js'
when :backbone then 'http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.0/backbone-min.js'
when :underscore then 'http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.1/underscore-min.js'
else script.to_s + '.js'
end
end
end
helpers JavaScripts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.