Class: Brandish::Processors::HTML::Header
- Inherits:
-
Common::Header
- Object
- Brandish::Processor::Base
- Common::Header
- Brandish::Processors::HTML::Header
- Includes:
- Hanami::Helpers::HtmlHelper
- Defined in:
- lib/brandish/processors/html/header.rb
Overview
A processor that defines the header
command. This creates a list
internally of all of the headers in the document, to later be used to
possibly create a table of contents, if needed.
This takes no options.
Pairs:
"level"
- Optional. Defaults to1
. The "level" of the header. This should be a value between 1 and 6."value"
- Required. The name of the header."id"
- Optional. The ID of the header. This is a unique value to reference to this header. If no value is given, it defaults to a modified"value"
."class"
- Optional. The class name of the header.
Constant Summary collapse
- TAGS =
The tags to use for each header level. This is just
h1
throughh6
. %i(h1 h2 h3 h4 h5 h6).freeze
Instance Attribute Summary
Attributes inherited from Brandish::Processor::Base
Instance Method Summary collapse
-
#header_render ⇒ ::String
Renders the proper HTML tag for the header, including the proper id, and an optional class value from the pairs.
Methods inherited from Common::Header
#header_data, #header_id, #header_level, #header_value, #perform, #setup
Methods included from Brandish::Processor::Command
included, #perform, #process_command
Methods inherited from Brandish::Processor::Base
#accept, #call, #initialize, #postprocess, #process_block, #process_command, #process_root, #process_text, register, #setup
Constructor Details
This class inherits a constructor from Brandish::Processor::Base
Instance Method Details
#header_render ⇒ ::String
Renders the proper HTML tag for the header, including the proper id, and an optional class value from the pairs.
39 40 41 42 |
# File 'lib/brandish/processors/html/header.rb', line 39 def header_render html.tag(TAGS.fetch(header_level - 1), header_value, id: header_id, class: @pairs.fetch("class", "")).to_s end |