I am starting to do forms and am looking for form helpers in Sinatra.
- Sinatra doesn’t seem to have built-in forms helpers.
- The helpers in Padrino look like what I’m after but I don’t feel up to porting my app to another framework. Plus it’s starting to look like a Rails application.
- I haven’t found any Sinatra forms helpers out there that are the ‘de facto’ choice.
Ideally, I’m after just a set of decent forms helpers that I can include as a gem and just start using, in place of hand-rolling all the base level erb/haml/ruby forms building.
What are your recommendations?
I find
sinatra-formhelpersuseful and used it in some projects. Have a look at their Github page, the code is pretty straightforward and might just be what you are looking for. Even if not, you could add your own specialized helpers easily. You can simply install it withand use it by requiring the Gem:
or, if you subclass
Sinatra::Base, by additionally including the helpers:After all, part of Sinatra’s philosophy is to be as light as possible. So if you want all the fancy things built in, Sinatra might just not be the right tool.