Created
April 9, 2011 14:44
-
-
Save sj26/911446 to your computer and use it in GitHub Desktop.
Nice nested layouts -- this does what *I* expect, at least.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= inside_layout :application do | |
%section.admin | |
%header ... | |
= yield | |
%footer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AdminController < ApplicationController | |
layout :admin | |
def index | |
render :dashboard | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!!! | |
%html | |
%head ... | |
%body | |
%header ... | |
= yield | |
%footer ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%h1 Dashboard | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module NestedLayoutsHelper | |
# Wrap some content inside a layout | |
def inside_layout(layout, &block) | |
layout = layout.to_s | |
layout = layout.include?('/') ? layout : "layouts/#{layout}" | |
controller.render_to_body(:layout => layout, :text => capture { block.call(@_content_for[:layout]) }) | |
end | |
end |
No, nestive is template-engine agnostic.
Originally, nestive requires you to declare layout nil
in your controllers and then use extends
in every template. I modified it so layout "application"
works as expected, with nested templating and areas available throughout.
capture { block.call(@_content_for[:layout]) })
should to be changed to capture { block.call(content_for :layout) })
at least it worked for me in 3.1.0.rc6
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the response!
Looking at your fork: https://github.com/sj26/nestive/commits/master
So does your fork support HAML, but justinfrench's does not?