Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adambeynon/opal-router
Router implementation for Opal (very alpha)
https://github.com/adambeynon/opal-router
Last synced: 4 months ago
JSON representation
Router implementation for Opal (very alpha)
- Host: GitHub
- URL: https://github.com/adambeynon/opal-router
- Owner: adambeynon
- Created: 2013-04-05T18:05:24.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-06-09T12:08:51.000Z (over 11 years ago)
- Last Synced: 2024-08-01T23:40:47.139Z (7 months ago)
- Language: Ruby
- Size: 160 KB
- Stars: 10
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-opal - Opal Router - Router implementation for Opal (very alpha) (Uncategorized / Uncategorized)
README
# opal-router
A simple router for Opal applications.
## Installation
Add to your Gemfile:
```ruby
gem 'opal-router', :git => 'git://github.com/adambeynon/opal-router.git'
```Then, anywhere in your opal code:
```ruby
require "opal-router"
```## Usage
```ruby
require "opal-router"router = Router.new
router.route("/users") do
puts "need to show all users"
endrouter.route("/users/:id") do |params|
puts "need to show user: #{ params[:id] }"
end# visit "example.com/#/users"
# visit "example.com/#/users/3"
# visit "example.com/#/users/5"# => "need to show all users"
# => need to show user: 3
# => need to show user: 5
```## TODO
* Support older browsers which do not support `onhashchange`.
* Support not-hash style routes with HTML5 routing.## License
MIT