0.0
No commit activity in last 3 years
No release in over 3 years
A very basic extension to Sinatra to return route arguments.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

#Sinatra arg

This is a very simple helper for Sinatra allowing you to quickly and easily get each argument within the url path.

##Installation: Install the gem:

gem install sinatra-arg

Require sinatra-arg

require 'sinatra-arg'

Done!

##Usage Anywhere within your Sinatra application you can now call arg() to get the value of any argument. For example if you had the route /blog/2012/11/23/getting-started you could use arg(0) to return blog and arg(4) to return getting-started.

##example require 'sinatra' require 'sinatra-arg'

get '/hello/:name' do
  erb "Hello #{arg(1).capitalize}"
end

get '/goodbye/:name' do
  erb "Goodbye #{arg(1).capitalize}"
end

__END__

@@ layout
<html>
<head>
  <% if arg(0) == 'hello' %>
    <link href="/css/hello.css" rel="stylesheet">
  <% else %>
    <link href="/css/other.css" rel="stylesheet">
  <% end %>
</head>
<body><%= yield %></body>
</html>

##Other information Sinatra arg was built by and is copyright of Tim Millwood who you can follow on Twitter.