class Hanami::Helpers::HtmlHelper::HtmlFragment

HTML Fragment

@since 0.2.6 @api private

@see Hanami::Helpers::HtmlHelper::HtmlFragment

Public Class Methods

new(&blk) click to toggle source

Initialize a HTML Fragment

@param blk [Proc,Hanami::Helpers::HtmlHelper::HtmlBuilder,NilClass] the content block

@return [Hanami::Helpers::HtmlHelper::HtmlFragment]

# File lib/hanami/helpers/html_helper/html_fragment.rb, line 18
def initialize(&blk)
  @builder = HtmlBuilder.new
  @blk = blk
end

Public Instance Methods

content() click to toggle source

@api private

# File lib/hanami/helpers/html_helper/html_fragment.rb, line 36
def content
  result = @builder.resolve(&@blk)

  if @builder.nested?
    @builder.to_s
  else
    Utils::Escape.html(result)
  end
end
to_s() click to toggle source

Resolve and return the output

@return [String] the output

@since 0.2.6 @api private

@see Hanami::Helpers::HtmlHelper::EmptyHtmlNode#to_s

# File lib/hanami/helpers/html_helper/html_fragment.rb, line 31
def to_s
  content.to_s
end