From e97d0ad0e482b349deddf2198ad96f3631cb6735 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sun, 30 Dec 2012 20:29:39 -0800 Subject: [PATCH] Allow non-templates to have frontmatter. Closes #698 --- middleman-core/features/front-matter.feature | 10 ++++++++++ .../frontmatter-app/source/raw-front-matter.html | 6 ++++++ .../frontmatter-app/source/raw-front-matter.php | 6 ++++++ .../lib/middleman-core/core_extensions/request.rb | 3 --- middleman-core/lib/middleman-core/sitemap/resource.rb | 4 +++- 5 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 middleman-core/fixtures/frontmatter-app/source/raw-front-matter.html create mode 100644 middleman-core/fixtures/frontmatter-app/source/raw-front-matter.php diff --git a/middleman-core/features/front-matter.feature b/middleman-core/features/front-matter.feature index b8d326c5..e7746063 100644 --- a/middleman-core/features/front-matter.feature +++ b/middleman-core/features/front-matter.feature @@ -11,6 +11,16 @@ Feature: YAML Front Matter Then I should see "<%= data.page.title %>" + Then I should not see "---" + When I go to "/raw-front-matter.php" + Then I should see '' + Then I should see "<%= data.page.title %> \ No newline at end of file diff --git a/middleman-core/fixtures/frontmatter-app/source/raw-front-matter.php b/middleman-core/fixtures/frontmatter-app/source/raw-front-matter.php new file mode 100644 index 00000000..dbc0dd37 --- /dev/null +++ b/middleman-core/fixtures/frontmatter-app/source/raw-front-matter.php @@ -0,0 +1,6 @@ +--- +layout: false +title: This is the title +--- + + \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/core_extensions/request.rb b/middleman-core/lib/middleman-core/core_extensions/request.rb index 7b4e2320..c16fbb18 100644 --- a/middleman-core/lib/middleman-core/core_extensions/request.rb +++ b/middleman-core/lib/middleman-core/core_extensions/request.rb @@ -244,9 +244,6 @@ module Middleman current_path = resource.destination_path - # If this path is a static file, send it immediately - return send_file(resource.source_file, env, res) unless resource.template? - # Set a HTTP content type based on the request's extensions content_type(res, resource.mime_type) diff --git a/middleman-core/lib/middleman-core/sitemap/resource.rb b/middleman-core/lib/middleman-core/sitemap/resource.rb index c0834d81..22ccd2f9 100644 --- a/middleman-core/lib/middleman-core/sitemap/resource.rb +++ b/middleman-core/lib/middleman-core/sitemap/resource.rb @@ -111,7 +111,9 @@ module Middleman # Render this resource # @return [String] def render(opts={}, locs={}, &block) - return File.open(source_file).read unless template? + if !template? + return app.template_data_for_file(source_file) + end relative_source = Pathname(source_file).relative_path_from(Pathname(app.root))