Sha256: 07d8c4ebcd1ad02535e4fb83efd3909b91ae53c958f423d95827bf94cdc6a5a5
Contents?: true
Size: 1.51 KB
Versions: 3
Compression:
Stored size: 1.51 KB
Contents
# encoding: utf-8 # frozen_string_literal: true require "hanami/helpers/html_helper" module Brandish module Processors module HTML # 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 to `1`. 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. class Header < Processors::Common::Header include Hanami::Helpers::HtmlHelper register %i(html header) => self pair :class # The tags to use for each header level. This is just `h1` through # `h6`. # # @return [::Symbol] TAGS = %i(h1 h2 h3 h4 h5 h6).freeze # Renders the proper HTML tag for the header, including the proper # id, and an optional class value from the pairs. # # @return [::String] def header_render html.tag(TAGS.fetch(header_level - 1), header_value, id: header_id, class: @pairs.fetch("class", "")).to_s end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
brandish-0.1.3 | lib/brandish/processors/html/header.rb |
brandish-0.1.2 | lib/brandish/processors/html/header.rb |
brandish-0.1.1 | lib/brandish/processors/html/header.rb |