views:

206

answers:

1

I want to be able to get Sinatra views from sub-directories of ./views (such as ./views/admin). I know you can set the views like so:

set :views, Proc.new { File.join(root, "templates") }

But how would I be able to set this for only part of the file?

+3  A: 

I'm not sure exactly what you're asking, but you can render a view in views/admin by doing this:

erb :"admin/report"

If you're asking how to automatically look in subdirectories of views when you call erb :report, I'm not sure how to do that, and I don't think you'd want to (what happens if two views in different dirs have the same name?).

Alex Reisner
It works, thanks. I have to leave off the file extension, though, it adds that automatically.
Ethan Turkeltaub
Oops--good point. I've removed the extension from the code in my answer.
Alex Reisner