Introduction
Sinatra is a free and open source programming web application library and space explicit language written in Ruby💎. It is an option in contrast to other Ruby web application systems like Ruby on Rails, Merb, Nitro, and Camping.
Sinatra is sufficiently strong to foster a working web application with simply a solitary document. Sinatra is perceived to be a decent way for fledgling engineers to get everything rolling in web application improvement in Ruby and can assist with planning in learning for more significant structures, including Rails.
The Bleeding Edge in Sinatra🎯

Independent Usage in Sinatra
Padrino is, as a matter of course, a full-stack system that gives countless upgrades to Sinatra and utilizations another base application Padrino::Application. Be that as it may, there are times when even Padrino itself is very 'heavyweight' for an application.🗃️
In these examples, the intelligent arrangement would be to carefully select individual improvements and use them in your current Sinatra application. Luckily, Padrino is focused on permitting you to do precisely that! Each significant part inside Padrino can be utilized in separation and applied to a current Sinatra application. This guide will walk you through that cycle for every detail.
Padrino Helpers🤝
This part gives a lot of view partners connected with the HTML markup age. There are partners for producing labels, structures, connections, and pictures, and that's just the beginning. Most essential strategies should be exceptionally natural to anyone using rails view aides.
You can look at the subtleties of these assistants in the Application Helpers guide. To enlist these partners inside your Sinatra application:
# app.rb
require 'sinatra/base'
require 'padrino-helpers'
class Application < Sinatra::Base
register Padrino::Helpers
endPadrino Mailer

This part gives a robust and straightforward mail conveyance framework inside Padrino🎩 (and Sinatra). There is full help for utilizing an HTML content sort concerning document connections. The Padrino Mailer has numerous likenesses to ActionMailer yet is much lighter-weight and more straightforward to use.
You can look at the subtleties of the mailer in the Padrino Mailer guide. To enroll this mailer inside your Sinatra application:
# app.rb
require 'sinatra/base'
require 'padrino-mailer'
class Application < Sinatra::Base
register Padrino::Mailer
mailer :sample do
email :birthday do |name, age|
subject 'Happy Birthday!'
to 'john@fake.com'
from 'noreply@birthday.com'
locals :name => name, :age => age
render 'sample/birthday'
end
end
endPadrino Routing
You can look at the subtleties of the directing framework in the Routing guide. To enroll the steering and regulator usefulness inside your Sinatra application:
# app.rb
require 'sinatra/base'
require 'padrino-core/application/routing'
#
# Small example that show you some padrino routes.
# Point your browser to:
#
# http://localhost:3000
# http://localhost:3000/bar
# http://localhost:3000/bar.js
# http://localhost:3000/custom-route/123
#
# These routes didn't work:
#
# http://localhost:3000/bar.xml
# http://localhost:3000/bar.jsl
# http://localhost:3000/custom-route
#
class MyApp < Sinatra::Application
register Padrino::Routing
get :foo, :map => "/" do
"This is foo mapped as index"
end
get :bar, :provides => [:js, :html] do
case content_type
when :js then "Bar for js"
when :html then "Bar for html"
else "You can never see this"
end
end
get :custom, :map => '/custom-route', :with => :id do
"This is a custom route with #{params[:id]} as params[:id]"
end
end # MyApp
MyApp.run!(:port => 3000)Padrino Rendering
Padrino improves the Sinatra 'render' strategy to support programmed layout motor location, among other further developed highlights.🧑💻
# app.rb
require 'sinatra/base'
require 'padrino-helpers'
class Application < Sinatra::Base
register Padrino::Rendering
get('/') { render 'example/demo' } # Auto-renders 'views/example/demo.haml'
get('/demo') { render :haml, 'example/demo' } # Renders 'views/example/demo.haml'
endPadrino Cache
Note that the padrino-store diamond doesn't at present do anything! This is a placeholder for when this jewel has been carried out.
# app.rb
require 'sinatra/base'
require 'padrino-cache'
class Application < Sinatra::Base
register Padrino::Cache
end
This will take into account the utilization of the storage usefulness inside Sinatra.
The Bleeding Edge
If you might want to utilize Sinatra's most recent extreme front-line code, go ahead and run your application against the expert branch; it ought to be pretty steady.
We likewise push out prerelease jewels occasionally so that you can do a
jewel introduce sinatra - - pre
To get probably the most recent highlights.





