Created
October 22, 2010 14:29
-
-
Save sinefunc/640631 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sinatra helper for jQuery. | |
# Usage: | |
# Instead of doing <script src="/js/jquery.js">, use: | |
# | |
# <%= jquery %> | |
# | |
class Main | |
helpers do | |
def jquery(path='/js/jquery.js', version='1.4.3') | |
if settings.production? | |
# Grab Google CDN's jQuery; fallback to local if necessary | |
"<script src=\"http://ajax.googleapis.com/ajax/libs/jquery/#{version}/jquery.min.js\"></script>"+ | |
"<script>!window.jQuery && document.write('<script src=\"#{path}\"><\\/script>')</script>" | |
else | |
"<script src='#{path}'></script>" | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment