1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00

test missing config error, fix nasty frontmatter caching bug. closes #209

This commit is contained in:
Thomas Reynolds 2011-12-22 21:19:49 -08:00
parent 3a5fc69a71
commit 4f78ecf367
7 changed files with 25 additions and 15 deletions

View file

@ -14,7 +14,7 @@ module Middleman
if !in_middleman_project? && !in_middleman_project_subdirectory?
$stderr.puts "== Error: Could not find a Middleman project config, perhaps you are in the wrong folder?"
return
exit(1)
end
if in_middleman_project?
@ -57,8 +57,7 @@ module Middleman
end
ARGV << "server" if ARGV.length < 1
if %w(server build migrate).include?(ARGV)
if %w(server s build b).include?(ARGV[0])
Middleman::ProjectLocator.locate_middleman_root!
else
Middleman::ProjectLocator.start_cli!

View file

@ -45,6 +45,10 @@ Feature: Builder
Scenario: Build with errors
Given a built app at "build-with-errors-app"
Then the exit status should be 1
Scenario: Build empty errors
Given a built app at "empty-app"
Then the exit status should be 1
Scenario: Build alias (b)
Given a fixture app "test-app"

View file

@ -12,8 +12,13 @@ Feature: Allow nesting of layouts
Given the Server is running at "nested-layout-app"
When I go to "/data-one.html"
Then I should see "Page Number One"
And I should see "Inner"
When I go to "/data-two.html"
Then I should see "Page Number Two"
And I should not see "Inner"
When I go to "/data-one.html"
Then I should see "Page Number One"
And I should see "Inner"
When I go to "/data-two.html"
Then I should see "Page Number Two"
And I should not see "Inner"

View file

View file

@ -1,5 +1,5 @@
---
title: Page Number One
layout: outer
layout: inner
---
Page #1

View file

@ -38,22 +38,18 @@ module Middleman::CoreExtensions::FrontMatter
provides_metadata matcher do |path|
relative_path = path.sub(source_dir, "")
data = if frontmatter.has_data?(relative_path)
fmdata = if frontmatter.has_data?(relative_path)
frontmatter.data(relative_path)[0]
else
{}
end
# Forward remaining data to helpers
data_content("page", data)
data = {}
%w(layout layout_engine).each do |opt|
if data.has_key?(opt)
data[opt.to_sym] = data.delete(opt)
end
data[opt.to_sym] = fmdata[opt] if fmdata.has_key?(opt)
end
{ :options => data }
{ :options => data, :page => fmdata }
end
end

View file

@ -36,7 +36,7 @@ module Middleman::Sitemap
def metadata
metadata = app.cache.fetch(:metadata, source_file) do
data = { :options => {}, :locals => {} }
data = { :options => {}, :locals => {}, :page => {} }
app.provides_metadata.each do |callback, matcher|
next if !matcher.nil? && !source_file.match(matcher)
@ -57,8 +57,14 @@ module Middleman::Sitemap
end
def render(opts={}, locs={}, &block)
opts = options.deep_merge(metadata[:options]).deep_merge(opts)
locs = locals.deep_merge(metadata[:locals]).deep_merge(locs)
md = metadata.dup
opts = options.deep_merge(md[:options]).deep_merge(opts)
locs = locals.deep_merge(md[:locals]).deep_merge(locs)
# Forward remaining data to helpers
if md.has_key?(:page)
app.data_content("page", md[:page])
end
blocks.compact.each do |block|
app.instance_eval(&block)