Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emk/sinatra-url-for
Construct absolute paths and full URLs to actions in a Sinatra application
https://github.com/emk/sinatra-url-for
Last synced: about 2 months ago
JSON representation
Construct absolute paths and full URLs to actions in a Sinatra application
- Host: GitHub
- URL: https://github.com/emk/sinatra-url-for
- Owner: emk
- License: other
- Created: 2009-04-22T11:34:39.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2011-03-07T14:55:08.000Z (over 13 years ago)
- Last Synced: 2024-07-05T15:03:18.548Z (3 months ago)
- Language: Ruby
- Homepage:
- Size: 122 KB
- Stars: 60
- Watchers: 5
- Forks: 11
- Open Issues: 2
-
Metadata Files:
- Readme: README.rdoc
- License: LICENSE
Awesome Lists containing this project
README
= sinatra-url-for
sinatra-url-for
constructs absolute paths and full URLs for
handlers in a Sinatra application. Assuming that your application is
running onexample.com
, and that it has been mapped to/myapp
, you should be able call +url_for+ from within a
handler as follows:url_for "/" # Returns "/myapp/"
url_for "/foo" # Returns "/myapp/foo"
url_for "/foo", :full # Returns "http://example.com/myapp/foo"To install it, run:
sudo gem install emk-sinatra-url-for -s http://gems.github.com
To include it in a Sinatra application, write:
require 'rubygems'
gem 'emk-sinatra-url-for'
require 'sinatra/url_for'If you're subclassing
Sinatra::Base
, then you need to callhelpers
manually:class MyApp < Sinatra::Base
helpers Sinatra::UrlForHelper
# ...
endThanks to "cypher23" on #mephisto and the folks on #rack for pointing me in
the right direction. If this gem fails to work correctly on your
system, please feel free to submit patches and/or bug reports!== Copyright
Copyright 2009 Eric Kidd. See LICENSE for details.