Make with_layout work with globs/regexes
This commit is contained in:
parent
5db1a9453a
commit
4a5fededf7
|
@ -13,6 +13,12 @@ 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 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"
|
||||||
|
|
|
@ -45,6 +45,9 @@ module Middleman::CoreExtensions::Routing
|
||||||
def page(url, opts={}, &block)
|
def page(url, opts={}, &block)
|
||||||
a_block = block_given? ? block : nil
|
a_block = block_given? ? block : nil
|
||||||
|
|
||||||
|
# Default layout
|
||||||
|
opts[:layout] = layout if opts[:layout].nil?
|
||||||
|
|
||||||
# If the url is a regexp
|
# If the url is a regexp
|
||||||
if url.is_a?(Regexp) || url.include?("*")
|
if url.is_a?(Regexp) || url.include?("*")
|
||||||
|
|
||||||
|
@ -56,9 +59,6 @@ module Middleman::CoreExtensions::Routing
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
# Default layout
|
|
||||||
opts[:layout] = layout if opts[:layout].nil?
|
|
||||||
|
|
||||||
# Normalized path
|
# Normalized path
|
||||||
url = full_path(url)
|
url = full_path(url)
|
||||||
|
|
||||||
|
@ -79,13 +79,9 @@ module Middleman::CoreExtensions::Routing
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# If we have a block or opts
|
# Setup a metadata matcher for rendering those options
|
||||||
if a_block || !opts.empty?
|
provides_metadata_for_path url do |url|
|
||||||
|
{ :options => opts, :blocks => [a_block] }
|
||||||
# Setup a metadata matcher for rendering those options
|
|
||||||
provides_metadata_for_path url do |url|
|
|
||||||
{ :options => opts, :blocks => [a_block] }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue