Sha256: 1a9d7f0d941858f15a5d61fb3488c9209486e44553fea2631bbbaed6d35f8317

Contents?: true

Size: 769 Bytes

Versions: 14

Compression:

Stored size: 769 Bytes

Contents

# Proxy component for content_for to prevent it from inserting the block's
# value into its location.
class ContentForProxy < Arbre::HTML::Tag
  builder_method :content_for

  def build(key, content = nil, &block)
    @value = helpers.content_for(key, content, &block)
  end

  def to_s
    @value
  end
end

# Patch to #capture to support Arbre::Element
module ActionView
  module Helpers
    module CaptureHelper
      def capture(*args)
        value = nil
        buffer = with_output_buffer { value = yield(*args) }
        value = value.to_s if value.is_a?(Arbre::Element) || value.is_a?(Arbre::ElementCollection)
        if string = buffer.presence || value and string.is_a?(String)
          ERB::Util.html_escape string
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
express_templates-0.11.20 lib/express_templates/components/content_for.rb
express_templates-0.11.20.rc1 lib/express_templates/components/content_for.rb
express_templates-0.11.19 lib/express_templates/components/content_for.rb
express_templates-0.11.18 lib/express_templates/components/content_for.rb
express_templates-0.11.17 lib/express_templates/components/content_for.rb
express_templates-0.11.16 lib/express_templates/components/content_for.rb
express_templates-0.11.16.rc1 lib/express_templates/components/content_for.rb
express_templates-0.11.15 lib/express_templates/components/content_for.rb
express_templates-0.11.14 lib/express_templates/components/content_for.rb
express_templates-0.11.13 lib/express_templates/components/content_for.rb
express_templates-0.11.11 lib/express_templates/components/content_for.rb
express_templates-0.11.10 lib/express_templates/components/content_for.rb
express_templates-0.11.9 lib/express_templates/components/content_for.rb
express_templates-0.11.8 lib/express_templates/components/content_for.rb