Skip to content

Instantly share code, notes, and snippets.

@bill-transue
Created February 7, 2012 16:41
Show Gist options
  • Save bill-transue/1760604 to your computer and use it in GitHub Desktop.
Save bill-transue/1760604 to your computer and use it in GitHub Desktop.
Reverse Nested Layouts...
-navigator "Sites", "# of Systems", "POC", "System Names", "Edit/Delete" do
=render Site.saved
.footer
=yield
.row
.cell
-if @site == site and params[:action] == "edit"
.navigator_cell_edit
-form_for @site do |f|
=f.text_field :name, :autofocus => true
.navigator_cell_save
=f.submit "Save", :class => "remote"
-else
=link_to site.name, site_systems_path(site), :remote => true
.cell
=site.systems.count
.cell
=site.poc
.cell
=site.systems.collect(&:coverterm).join ", "
.cell
=link_to image_tag("edit2.png", :size => "18x18", :title => "Edit #{site.name}"), edit_site_path(site), :remote => true
=link_to image_tag("delete2.png", :size => "18x18", :title => "Delete #{site.name}"), site, :confirm => "Are you sure?", :method => "delete", :remote => true
!!! 5
%html
%head
%title
Blah
=stylesheet_link_tag 'application', :media => 'all'
=stylesheet_link_tag 'blueprint/print', :media => 'print'
=javascript_include_tag 'application'
=csrf_meta_tags
=yield :head
%body
#header
=render :partial => "layouts/header"
=render :partial => "layouts/flash"
-if content_for? :content
=yield :content
-else
=yield
#footer
=render :partial => "layouts/footer"
module ApplicationHelper
def navigator(*columns, &block)
haml_tag :div, :id => "navigator", :class => "table" do
haml_tag :div, :class => "header" do
columns.each do |column|
haml_tag :div do
haml_concat column
end
end
end
yield
end
end
end
=link_to "New Site", new_site_path, :remote => true
-form_for @site do |f|
=f.text_field :name, :autofocus => true
.navigator_cell_submit
=f.submit "Submit", :remote => true
-content_for :content do
=render 'breadcrumb'
=render 'navigator'
=render :file => 'layouts/application'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment