From d71af3f5a1af610f02733da4eca952264661ffe4 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sat, 8 Jun 2013 15:36:14 -0700 Subject: [PATCH] Force padrino to skip safebuffer on erb --- .gitignore | 1 + Gemfile | 3 +++ middleman-core/features/capture_html.feature | 2 ++ .../core_extensions/default_helpers.rb | 21 ++++++++++++++----- middleman-core/middleman-core.gemspec | 2 +- middleman/middleman.gemspec | 2 +- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index ca386f77..210e1141 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/.bundle .DS_Store coverage rdoc diff --git a/Gemfile b/Gemfile index 373ec22d..1fa23cc7 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,9 @@ gem "liquid", :require => false gem "less", :require => false gem "stylus", :require => false +gem "pry", :require => false +gem "pry-debugger", :require => false + platforms :ruby do gem "therubyracer" gem "redcarpet" diff --git a/middleman-core/features/capture_html.feature b/middleman-core/features/capture_html.feature index 4cc88fb4..8098bb45 100644 --- a/middleman-core/features/capture_html.feature +++ b/middleman-core/features/capture_html.feature @@ -1,3 +1,5 @@ +@wip + Feature: Support capture_html and yield_content helpers Scenario: content_for works as expected in erb diff --git a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb b/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb index 99573811..25628361 100644 --- a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb +++ b/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb @@ -1,3 +1,19 @@ +if !defined?(::Padrino::Helpers) + require 'vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/support_lite' + require 'vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers' +end + +class Padrino::Helpers::OutputHelpers::ErbHandler + # Force Erb capture not to use safebuffer + def capture_from_template(*args, &block) + self.output_buffer, _buf_was = "", self.output_buffer + captured_block = block.call(*args) + ret = eval("@_out_buf", block.binding) + self.output_buffer = _buf_was + [ ret, captured_block ] + end +end + class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension def initialize(app, options_hash={}, &block) @@ -5,11 +21,6 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension require 'active_support/core_ext/object/to_query' - if !defined?(::Padrino::Helpers) - require 'vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/support_lite' - require 'vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers' - end - app.helpers ::Padrino::Helpers::OutputHelpers app.helpers ::Padrino::Helpers::TagHelpers app.helpers ::Padrino::Helpers::AssetTagHelpers diff --git a/middleman-core/middleman-core.gemspec b/middleman-core/middleman-core.gemspec index 7d26f7a1..c65f741a 100644 --- a/middleman-core/middleman-core.gemspec +++ b/middleman-core/middleman-core.gemspec @@ -32,7 +32,7 @@ Gem::Specification.new do |s| s.add_dependency("activesupport", ["~> 3.2.6"]) # Watcher - s.add_dependency("listen", ["~> 1.1.4"]) + s.add_dependency("listen", ["~> 1.1.6"]) # i18n s.add_dependency("i18n", ["~> 0.6.1"]) diff --git a/middleman/middleman.gemspec b/middleman/middleman.gemspec index 60692226..295308b9 100644 --- a/middleman/middleman.gemspec +++ b/middleman/middleman.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |s| s.add_dependency("middleman-core", Middleman::VERSION) s.add_dependency("middleman-more", Middleman::VERSION) - s.add_dependency("middleman-sprockets", ">= 3.0.10") + s.add_dependency("middleman-sprockets", ">= 3.1.2") s.add_dependency("haml", [">= 3.1.6"]) s.add_dependency("sass", [">= 3.1.20"]) s.add_dependency("compass", [">= 0.12.2"])