#17 √ resolved
Jon Maddox

default layout doesn't work with nested templates

Reported by Jon Maddox | May 4th, 2008 @ 09:52 PM | in 0.3.0 Sammy

The default layout declared isn't shared with templates that are nested in directories.

get '/repositories/new' do
  haml :new, :views_directory => 'views/repositories'
end

Comments and changes to this ticket

  • Ryan Tomayko

    Ryan Tomayko May 5th, 2008 @ 01:54 AM

    Interesting. I don't think I've ever used multiple directories under views or this would have jumped out at me. Seems like we should support paths in the template name but the use of Symbol is going to make that a little weird.

    Out of curiosity, what happens you do something like this:

    get '/repositories/new' do
      haml :'repositories/new'
    end
    

    The syntax is valid but does it work as expected with layouts and everything?

  • chris (at christopher-schneider)

    chris (at christopher-schneider) May 26th, 2008 @ 09:17 AM

    A quick bit of investigation indicates that the string as a symbol method that Ryan suggested works fine.

    I have a directory structure like:

    thingy.rb
    views/layout.erb
    views/thing/new.erb
    views/thing/layout.erb
    

    The two layout files are different, so I can tell which one gets called.

    The thingy.rb calls:

    get '/' do
        erb :'thing/new'
    end
    

    The two files that get used are:

    views/layout.erb
    views/thing/new.erb
    

    So in the end, it looks like nested views work ok, but it doesn't catch nested layouts. I'm not sure what the correct behavior with nested layouts would be though.

  • Blake Mizerany

    Blake Mizerany May 26th, 2008 @ 02:48 PM

    for now try

    erb :'thing/new', :layout => :'thing/layout'
    
  • chris (at christopher-schneider)

    chris (at christopher-schneider) May 28th, 2008 @ 07:16 PM

    What is the next step on this? I did some investigation, and I think we have a good idea of what the status is.

    Is this really a bug, or is this closed, or maybe just a feature request?

  • Ryan Tomayko

    Ryan Tomayko September 7th, 2008 @ 06:29 PM

    • → Tag changed from “” to “bug”
    • → Assigned user changed from “Blake Mizerany” to “Ryan Tomayko”
  • Ryan Tomayko

    Ryan Tomayko September 7th, 2008 @ 06:31 PM

    • → Tag cleared.
    • → State changed from “new” to “resolved”

    Let's call this one closed. Feel free to yell really loud and we'll reopen if this still effects you.

  • jazzmyn,

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Attachments