Sha256: 3c782eb1acc60a85e8fd2508a9a48c0a755497dd637343fe04526bc0bcd9c3fe
Contents?: true
Size: 1003 Bytes
Versions: 12
Compression:
Stored size: 1003 Bytes
Contents
# frozen_string_literal: true module Alchemy module Ingredients # A text headline # class Headline < Alchemy::Ingredient include DomIds store_accessor :data, :dom_id, :level, :size allow_settings %i[ anchor levels sizes ] before_create :set_level_and_size def preview_text(maxlength = 30) "H#{level}: #{value}"[0..maxlength - 1] end def level_options levels.map { |level| ["H#{level}", level] } end def size_options sizes.map do |size| case size when Array size else [".h#{size}", size] end end end private def levels settings.fetch(:levels, (1..6)) end def sizes settings.fetch(:sizes, []) end def set_level_and_size self.level ||= levels.first self.size ||= sizes.first end end end end
Version data entries
12 entries across 12 versions & 1 rubygems