Last Updated: February 25, 2016
·
1.6K
· rsludge

Use multiple template folders in Sinatra

By default Sinatra renders templates from views directory. To override this you can set views option:

set :views, 'views_directory_name'

But if you want to use templates from multiple directories you should also override find_template method:

configure do
  set :views, ['views', 'some_other_directory']
end

helpers do
  def find_template(views, name, engine, &block)
    views.each { |v| super(v, name, engine, &block) }
  end
end

Link to related github issue: https://github.com/sinatra/sinatra/issues/48