From 47eb29bcfec2e1cc211964a1842c9dbfec11e6e8 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Fri, 18 Nov 2011 21:46:26 -0800 Subject: [PATCH] fix template read cache --- features/custom_layout_engines.feature | 10 ++++++++++ fixtures/custom-layout-app/config.rb | 1 + fixtures/custom-layout-app/source/index.html.erb | 1 + fixtures/custom-layout-app/source/layout.haml | 6 ++++++ lib/middleman/base.rb | 8 ++++---- lib/middleman/core_extensions/front_matter.rb | 4 ++-- 6 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 features/custom_layout_engines.feature create mode 100644 fixtures/custom-layout-app/config.rb create mode 100755 fixtures/custom-layout-app/source/index.html.erb create mode 100644 fixtures/custom-layout-app/source/layout.haml diff --git a/features/custom_layout_engines.feature b/features/custom_layout_engines.feature new file mode 100644 index 00000000..5963efd1 --- /dev/null +++ b/features/custom_layout_engines.feature @@ -0,0 +1,10 @@ +Feature: Custom Layout Engine + + Scenario: Checking built folder for content + Given a built app at "custom-layout-app" + Then "index.html" should exist at "custom-layout-app" and include "Comment in layout" + + Scenario: Checking server for content + Given the Server is running at "test-app" + When I go to "/index.html" + Then I should see "Comment in layout" \ No newline at end of file diff --git a/fixtures/custom-layout-app/config.rb b/fixtures/custom-layout-app/config.rb new file mode 100644 index 00000000..93b5f327 --- /dev/null +++ b/fixtures/custom-layout-app/config.rb @@ -0,0 +1 @@ +set :erb, :layout_engine => :haml \ No newline at end of file diff --git a/fixtures/custom-layout-app/source/index.html.erb b/fixtures/custom-layout-app/source/index.html.erb new file mode 100755 index 00000000..f47aba51 --- /dev/null +++ b/fixtures/custom-layout-app/source/index.html.erb @@ -0,0 +1 @@ +

Welcome

\ No newline at end of file diff --git a/fixtures/custom-layout-app/source/layout.haml b/fixtures/custom-layout-app/source/layout.haml new file mode 100644 index 00000000..e5a7a094 --- /dev/null +++ b/fixtures/custom-layout-app/source/layout.haml @@ -0,0 +1,6 @@ +%html + %head + %title My Sample Site + / Comment in layout + %body + = yield \ No newline at end of file diff --git a/lib/middleman/base.rb b/lib/middleman/base.rb index 09056ef8..dc467ec3 100644 --- a/lib/middleman/base.rb +++ b/lib/middleman/base.rb @@ -316,11 +316,11 @@ public end def read_raw_template(path) - if !raw_templates_cache.has_key?(path) - raw_templates_cache[path] = File.read(path) + if raw_templates_cache.has_key?(path) + raw_templates_cache[path] + else + File.read(path) end - - raw_templates_cache[path] end def map(map, &block) diff --git a/lib/middleman/core_extensions/front_matter.rb b/lib/middleman/core_extensions/front_matter.rb index 184214d6..e86af699 100644 --- a/lib/middleman/core_extensions/front_matter.rb +++ b/lib/middleman/core_extensions/front_matter.rb @@ -69,14 +69,14 @@ module Middleman::CoreExtensions::FrontMatter file = File.expand_path(file, @app.root) content = File.read(file) - file = file.sub(@app.source_dir, "") # @app.logger.debug :frontmatter_update, Time.now, file if @app.logging? result = parse_front_matter(content) if result + file = file.sub(@app.source_dir, "") @local_data[file] = result - path = @app.extensionless_path(file) + path = File.join(@app.source_dir, file) @app.raw_templates_cache[path] = result[1] end end