Sinatra Wardrobe
A way to dress up Sinatra with static file routing based on a few params.
Require in your Gemfile
gem 'sinatra-wardrobe'And use it with the suit_up! method.
suit_up! directories: './views', extensions: '.md'Or, for a little more control:
suit_up! directories: ['./views/blog', './views/static'], extensions: ['.md', '.erb'], excludes: 'layout.erb', layout_engine: :erbDefaults
By default, Sinatra::Wardrobe will look for files with a .md extension in the ./views directory, ignoring layout.erb and assuming a layout_engine of :erb.
Currently it only supports .erb, .md and .markdown but there are more to come.
Helpers
-
hatswill return the array of Hash objects thatSinatra::Wardrobeuses to bind thegetrequests and serve your files. -
hat_rackis an HTML helper that generates an (by default) unordered list with links to each of the files in thehatsarray.