Removed wrap_layout

This commit is contained in:
Thomas Reynolds 2014-05-25 12:23:00 +09:00
parent 4ab88e6577
commit f89a76747e
14 changed files with 29 additions and 103 deletions

View file

@ -1,6 +1,7 @@
master master
=== ===
* Removed `with_layout`. Use loops of `page` instead.
* Removed Queryable Sitemap API * Removed Queryable Sitemap API
* Removed `css_compressor` setting, use `activate :minify_css, :compressor =>` instead. * Removed `css_compressor` setting, use `activate :minify_css, :compressor =>` instead.
* Removed `js_compressor` setting, use `activate :minify_javascript, :compressor =>` instead. * Removed `js_compressor` setting, use `activate :minify_javascript, :compressor =>` instead.

View file

@ -7,18 +7,6 @@ Feature: Custom layouts
When I go to "/custom-layout.html" When I go to "/custom-layout.html"
Then I should see "Custom Layout" Then I should see "Custom Layout"
Scenario: Using with_layout block
Given "/custom-layout.html" with_layout block has layout "custom"
And the Server is running at "custom-layout-app2"
When I go to "/custom-layout.html"
Then I should see "Custom Layout"
Scenario: Using with_layout block with globs
Given "/custom-*" with_layout block has layout "custom"
And the Server is running at "custom-layout-app2"
When I go to "/custom-layout.html"
Then I should see "Custom Layout"
Scenario: Using custom :layout attribute with folders Scenario: Using custom :layout attribute with folders
Given page "/custom-layout-dir/" has layout "custom" Given page "/custom-layout-dir/" has layout "custom"
And the Server is running at "custom-layout-app2" And the Server is running at "custom-layout-app2"

View file

@ -4,12 +4,3 @@ Given /^page "([^\"]*)" has layout "([^\"]*)"$/ do |url, layout|
page(url, :layout => layout.to_sym) page(url, :layout => layout.to_sym)
} }
end end
Given /^"([^\"]*)" with_layout block has layout "([^\"]*)"$/ do |url, layout|
@initialize_commands ||= []
@initialize_commands << lambda {
with_layout(layout.to_sym) do
page(url)
end
}
end

View file

@ -1,4 +1,3 @@
with_layout false do
%w{ %w{
/auto-css.html /auto-css.html
/auto-css /auto-css
@ -6,6 +5,5 @@ with_layout false do
/auto-css/auto-css.html /auto-css/auto-css.html
/auto-css/sub/auto-css.html /auto-css/sub/auto-css.html
}.each do |path| }.each do |path|
page path page path, layout: false
end
end end

View file

@ -1,4 +1,3 @@
with_layout false do
%w{ %w{
/auto-js.html /auto-js.html
/auto-js /auto-js
@ -6,6 +5,5 @@ with_layout false do
/auto-js/auto-js.html /auto-js/auto-js.html
/auto-js/sub/auto-js.html /auto-js/sub/auto-js.html
}.each do |path| }.each do |path|
page path page path, layout: false
end
end end

View file

@ -1,4 +1,2 @@
with_layout false do page "/data.html", layout: false
page "/data.html" page "/data3.html", layout: false
page "/data3.html"
end

View file

@ -1,7 +1,5 @@
require "slim" require "slim"
with_layout :capture_html do page "/capture_html_erb.html", layout: :capture_html
page "/capture_html_erb.html" page "/capture_html_haml.html", layout: :capture_html
page "/capture_html_haml.html" page "/capture_html_slim.html", layout: :capture_html
page "/capture_html_slim.html"
end

View file

@ -1,7 +1,5 @@
require "slim" require "slim"
with_layout :content_for do page "/content_for_erb.html", layout: :content_for
page "/content_for_erb.html" page "/content_for_haml.html", layout: :content_for
page "/content_for_haml.html" page "/content_for_slim.html", layout: :content_for
page "/content_for_slim.html"
end

View file

@ -22,11 +22,6 @@
# #
# With alternative layout # With alternative layout
# page "/path/to/file.html", :layout => :otherlayout # page "/path/to/file.html", :layout => :otherlayout
#
# A path which all have the same layout
# with_layout :admin do
# page "/admin/*"
# end
# Proxy (fake) files # Proxy (fake) files
# page "/this-page-has-no-template.html", :proxy => "/template-file.html" do # page "/this-page-has-no-template.html", :proxy => "/template-file.html" do

View file

@ -1,3 +1 @@
with_layout false do page "/spaces in file.html", layout: false
page "/spaces in file.html"
end

View file

@ -1,4 +1,2 @@
with_layout false do page "/sub1/page-classes.html", layout: false
page "/sub1/page-classes.html" page "/sub1/sub2/page-classes.html", layout: false
page "/sub1/sub2/page-classes.html"
end

View file

@ -1,6 +1,6 @@
module Middleman module Middleman
class ConfigContext class ConfigContext
# with_layout and page routing # page routing
include Middleman::CoreExtensions::Routing include Middleman::CoreExtensions::Routing
attr_reader :app attr_reader :app

View file

@ -2,36 +2,6 @@
module Middleman module Middleman
module CoreExtensions module CoreExtensions
module Routing module Routing
# Sandboxed layout to implement temporary overriding of layout.
class LayoutBlock
attr_reader :scope
def initialize(scope, layout_name)
@scope = scope
@layout_name = layout_name
end
def page(url, opts={})
opts[:layout] ||= @layout_name
@scope.page(url, opts)
end
delegate :proxy, to: :scope
end
# Takes a block which allows many pages to have the same layout
#
# with_layout :admin do
# page "/admin/"
# page "/admin/login.html"
# end
#
# @param [String, Symbol] layout_name
# @return [void]
def with_layout(layout_name, &block)
LayoutBlock.new(self, layout_name).instance_eval(&block)
end
# The page method allows the layout to be set on a specific path # The page method allows the layout to be set on a specific path
# #
# page "/about.html", :layout => false # page "/about.html", :layout => false

View file

@ -20,11 +20,6 @@ page '/*.txt', layout: false
# #
# With alternative layout # With alternative layout
# page "/path/to/file.html", :layout => :otherlayout # page "/path/to/file.html", :layout => :otherlayout
#
# A path which all have the same layout
# with_layout :admin do
# page "/admin/*"
# end
# Proxy pages (http://middlemanapp.com/basics/dynamic-pages/) # Proxy pages (http://middlemanapp.com/basics/dynamic-pages/)
# proxy "/this-page-has-no-template.html", "/template-file.html", :locals => { # proxy "/this-page-has-no-template.html", "/template-file.html", :locals => {