Class: FoxPage::Helpers::TagHelper::TagBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/fox_page/helpers/tag_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(name:, content: nil, options: {}) ⇒ TagBuilder

Returns a new instance of TagBuilder.



7
8
9
10
11
# File 'lib/fox_page/helpers/tag_helper.rb', line 7

def initialize(name:, content: nil, options: {})
  @name = name
  @content = content
  @options = options
end

Instance Method Details

#buildObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fox_page/helpers/tag_helper.rb', line 13

def build
  [
    "<",
    [
      @name.to_s,
      *@options.compact.map(&method(:tag_option)),
    ].join(" "),
    ">",
    @content,
    "</",
    @name.to_s,
    ">"
  ].join("")
end