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
Written by Oleg Potapov
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Sinatra
Authors
Related Tags
#sinatra
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#