Sha256: 0696a7584c411ddea8193ae881699a75b25c97f01a73ae9fe3497c45333cf3e2

Contents?: true

Size: 826 Bytes

Versions: 6

Compression:

Stored size: 826 Bytes

Contents

# frozen_string_literal: true

class Scarpe
  class GlimmerLibUITextWidget < Scarpe::GlimmerLibUIWidget
  end

  class << self
    def default_glibui_text_widget_with(element)
      class_name = "GlimmerLibUI#{element.capitalize}"
      widget_class = Class.new(Scarpe::GlimmerLibUITextWidget) do
        def initialize(properties)
          class_name = self.class.name.split("::")[-1]
          @html_tag = class_name.delete_prefix("GlimmerLibUI").downcase
          super
        end

        def element
          HTML.render do |h|
            h.send(@html_tag) { @content.to_s }
          end
        end
      end
      Scarpe.const_set class_name, widget_class
    end
  end
end

Scarpe.default_glibui_text_widget_with(:code)
Scarpe.default_glibui_text_widget_with(:em)
Scarpe.default_glibui_text_widget_with(:strong)

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
scarpe-0.4.0 spikes/glibui/text_widget.rb
scarpe-0.3.0 spikes/glibui/text_widget.rb
scarpe-0.2.2 spikes/glibui/text_widget.rb
lacci-0.2.1 lib/scarpe/glibui/text_widget.rb
scarpe-0.2.1 lib/scarpe/glibui/text_widget.rb
scarpe-0.2.0 lib/scarpe/glibui/text_widget.rb