Class: Hanami::Helpers::HtmlHelper::HtmlBuilder

Inherits:
Object
  • Object
show all
Includes:
Utils::ClassAttribute
Defined in:
gems/gems/hanami-helpers-1.3.0/lib/hanami/helpers/html_helper/html_builder.rb

Overview

HTML Builder

Since:

  • 0.1.0

Direct Known Subclasses

FormHelper::FormBuilder

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &blk) ⇒ Object

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.

Forward missing methods to the current context. This allows to access views local variables from nested content blocks.

Since:

  • 0.1.0

def method_missing(method_name, *args, &blk) # rubocop:disable Style/MethodMissingSuper
  @context.__send__(method_name, *args, &blk)
end

Instance Method Details

#text(content) ⇒ self Also known as: +

Defines a plain string of text. This particularly useful when you want to build more complex HTML.

Examples:


<%=
  html.label do
    text "Option 1"
    radio_button :option, 1
  end
%>

<!-- output -->
<label>
  Option 1
  <input type="radio" name="option" value="1" />
</label>

Parameters:

  • content (String)

    the text to be rendered.

Returns:

  • (self)

See Also:

Since:

  • 0.1.0

def text(content)
  @nodes << TextNode.new(content)
  self
end