Class: Hanami::Helpers::HtmlHelper::HtmlFragment Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/helpers/html_helper/html_fragment.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

HTML Fragment

See Also:

Since:

  • 0.2.6

Instance Method Summary collapse

Constructor Details

#initialize(&blk) ⇒ Hanami::Helpers::HtmlHelper::HtmlFragment

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize a HTML Fragment

Parameters:

Since:

  • 0.2.6



18
19
20
21
# File 'lib/hanami/helpers/html_helper/html_fragment.rb', line 18

def initialize(&blk)
  @builder = HtmlBuilder.new
  @blk = blk
end

Instance Method Details

#contentObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.2.6



36
37
38
39
40
41
42
43
44
# 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_sString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Resolve and return the output

Returns:

  • (String)

    the output

See Also:

Since:

  • 0.2.6



31
32
33
# File 'lib/hanami/helpers/html_helper/html_fragment.rb', line 31

def to_s
  content.to_s
end