From 2ed409b5e1fa77188384f39c54a9de4cc964b11b Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Tue, 29 Nov 2011 11:49:42 -0800 Subject: [PATCH] make sure chained templates work with data --- features/chained_templates.feature | 9 +++++++++ fixtures/chained-app/config.rb | 0 fixtures/chained-app/data/article.yml | 2 ++ fixtures/chained-app/source/index.html.markdown.erb | 8 ++++++++ lib/middleman/core_extensions/rendering.rb | 8 ++++++-- middleman.gemspec | 2 +- 6 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 features/chained_templates.feature create mode 100644 fixtures/chained-app/config.rb create mode 100644 fixtures/chained-app/data/article.yml create mode 100755 fixtures/chained-app/source/index.html.markdown.erb diff --git a/features/chained_templates.feature b/features/chained_templates.feature new file mode 100644 index 00000000..1fd0699d --- /dev/null +++ b/features/chained_templates.feature @@ -0,0 +1,9 @@ +Feature: Templates should be chainable + In order to insert variables and data in "static" engines + + Scenario: Data in Erb in Markdown + Given the Server is running at "chained-app" + When I go to "/index.html" + Then I should see "Title" + And I should see "Subtitle" + And I should see "Sup" \ No newline at end of file diff --git a/fixtures/chained-app/config.rb b/fixtures/chained-app/config.rb new file mode 100644 index 00000000..e69de29b diff --git a/fixtures/chained-app/data/article.yml b/fixtures/chained-app/data/article.yml new file mode 100644 index 00000000..2a8f7c7c --- /dev/null +++ b/fixtures/chained-app/data/article.yml @@ -0,0 +1,2 @@ +title: "Title" +subtitle: "Subtitle" \ No newline at end of file diff --git a/fixtures/chained-app/source/index.html.markdown.erb b/fixtures/chained-app/source/index.html.markdown.erb new file mode 100755 index 00000000..17a0f29a --- /dev/null +++ b/fixtures/chained-app/source/index.html.markdown.erb @@ -0,0 +1,8 @@ +--- +layout: false +sup: "Sup" +--- + +# <%= data.article.title %> +## <%= data.article.subtitle %> +### <%= data.page.sup %> \ No newline at end of file diff --git a/lib/middleman/core_extensions/rendering.rb b/lib/middleman/core_extensions/rendering.rb index d9d7b8c7..41ff1546 100644 --- a/lib/middleman/core_extensions/rendering.rb +++ b/lib/middleman/core_extensions/rendering.rb @@ -40,8 +40,12 @@ module Middleman::CoreExtensions::Rendering @current_engine, engine_was = engine, @current_engine @_out_buf, _buf_was = "", @_out_buf - - content = render_individual_file(path, locs, opts) + + while ::Tilt[path] + content = render_individual_file(path, locs, opts) + path = File.basename(path, File.extname(path)) + cache.set([:raw_template, path], content) + end needs_layout = !%w(.js .css .txt).include?(extension) diff --git a/middleman.gemspec b/middleman.gemspec index 2170a171..71c3bd9b 100644 --- a/middleman.gemspec +++ b/middleman.gemspec @@ -34,7 +34,7 @@ Gem::Specification.new do |s| s.add_dependency("coffee-script", ["~> 2.2.0"]) s.add_dependency("execjs", ["~> 1.2.7"]) s.add_dependency("sprockets", ["~> 2.1.2"]) - s.add_dependency("sprockets-sass", ["~> 0.3.0"]) + s.add_dependency("sprockets-sass", ["~> 0.5.0"]) s.add_dependency("guard", ["~> 0.8.8"]) # OSX