jlong / serve

Serve is a small Rack-based web server and rapid prototyping framework for Web applications (specifically Rails apps). Serve is meant to be a lightweight version of the Views part of the Rails MVC. This makes Serve an ideal framework for prototyping Rails applications or creating simple websites. Serve has full support for Rails-style partials and layouts.
http://get-serve.com
Other
836 stars 90 forks source link

Views directories not being traversed for templates in multiple subdirectories #95

Open aitor opened 11 years ago

aitor commented 11 years ago

According the documentation:

Serve searches for a layout file in the same directory as the view. If it fails to find one there, it traverses up the directory tree searching each parent directory until it finds the "nearest" layout. http://get-serve.com/documentation/layouts

Borrowing the example from gem's site:

views/
  |
  _layout.erb
  |
  +-- index.erb (A)
  |
  `-- about/
        |
        `-- index.erb (B)
  `-- team/
        `-- sales/
            |
            `-- index.erb (C)
        `-- dev/
            |
            `-- index.erb (D)

It's my understanding that all cases, A,B,C and D should use the same layout (_layout.erb), but currently only A and B are correctly working.

The current pipeline implementation is using File#split (see pipeline.rb) for generating an array with the possible locations for layouts and therefore expecting layout to be in one of the following locations:

   => "app/views/team/sales/_layout.erb"
   => "app/views/team/_layout.erb"

This implementation will, as consequence, check always just two levels for each template (its current dir and its parent). Before doing the pull request with a fix I'd like to confirm with @jlong or any other familiar with the codebase if this is a real bug and not a feature :).

jlong commented 11 years ago

Ah yes. This is actually a regression. It should function as it says in the docs. Pull-request away!

bluesaunders commented 11 years ago

Would just like to chime in that I'm running into this as well. (Though I'm a front-end guy and thus can't fix it and submit a pull-request.)