Force padrino to skip safebuffer on erb

This commit is contained in:
Thomas Reynolds 2013-06-08 15:36:14 -07:00
parent d9f8327dc6
commit d71af3f5a1
6 changed files with 24 additions and 7 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
/.bundle
.DS_Store .DS_Store
coverage coverage
rdoc rdoc

View file

@ -19,6 +19,9 @@ gem "liquid", :require => false
gem "less", :require => false gem "less", :require => false
gem "stylus", :require => false gem "stylus", :require => false
gem "pry", :require => false
gem "pry-debugger", :require => false
platforms :ruby do platforms :ruby do
gem "therubyracer" gem "therubyracer"
gem "redcarpet" gem "redcarpet"

View file

@ -1,3 +1,5 @@
@wip
Feature: Support capture_html and yield_content helpers Feature: Support capture_html and yield_content helpers
Scenario: content_for works as expected in erb Scenario: content_for works as expected in erb

View file

@ -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 class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
def initialize(app, options_hash={}, &block) def initialize(app, options_hash={}, &block)
@ -5,11 +21,6 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
require 'active_support/core_ext/object/to_query' 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::OutputHelpers
app.helpers ::Padrino::Helpers::TagHelpers app.helpers ::Padrino::Helpers::TagHelpers
app.helpers ::Padrino::Helpers::AssetTagHelpers app.helpers ::Padrino::Helpers::AssetTagHelpers

View file

@ -32,7 +32,7 @@ Gem::Specification.new do |s|
s.add_dependency("activesupport", ["~> 3.2.6"]) s.add_dependency("activesupport", ["~> 3.2.6"])
# Watcher # Watcher
s.add_dependency("listen", ["~> 1.1.4"]) s.add_dependency("listen", ["~> 1.1.6"])
# i18n # i18n
s.add_dependency("i18n", ["~> 0.6.1"]) s.add_dependency("i18n", ["~> 0.6.1"])

View file

@ -19,7 +19,7 @@ Gem::Specification.new do |s|
s.add_dependency("middleman-core", Middleman::VERSION) s.add_dependency("middleman-core", Middleman::VERSION)
s.add_dependency("middleman-more", 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("haml", [">= 3.1.6"])
s.add_dependency("sass", [">= 3.1.20"]) s.add_dependency("sass", [">= 3.1.20"])
s.add_dependency("compass", [">= 0.12.2"]) s.add_dependency("compass", [">= 0.12.2"])