Sha256: 0f2717373e4027aa677eab5e6417a04289a5e95b4f381d3178746a1250a2fcd5

Contents?: true

Size: 533 Bytes

Versions: 3

Compression:

Stored size: 533 Bytes

Contents

# frozen_string_literal: true

module Primer
  # Module to allow shorthand calls for Primer components
  module ViewHelper
    class ViewHelperNotFound < StandardError; end

    HELPERS = {
      octicon: "Primer::OcticonComponent",
      heading: "Primer::HeadingComponent",
      time_ago: "Primer::TimeAgoComponent"
    }.freeze

    HELPERS.each do |name, component|
      define_method "primer_#{name}" do |**component_args, &block|
        render component.constantize.new(**component_args), &block
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
primer_view_components-0.0.31 app/lib/primer/view_helper.rb
primer_view_components-0.0.30 app/lib/primer/view_helper.rb
primer_view_components-0.0.29 app/lib/primer/view_helper.rb