Sha256: 52245823a0772d43475e6e857fe68083ae0f6a4c9ee450052fa7e1c7715dc4e1

Contents?: true

Size: 568 Bytes

Versions: 14

Compression:

Stored size: 568 Bytes

Contents

# frozen_string_literal: true

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

    HELPERS = {
      octicon: "Primer::OcticonComponent",
      heading: "Primer::Beta::Heading",
      time_ago: "Primer::TimeAgoComponent",
      image: "Primer::Image"
    }.freeze

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
primer_view_components-0.0.104 app/lib/primer/view_helper.rb
primer_view_components-0.0.103 app/lib/primer/view_helper.rb
primer_view_components-0.0.102 app/lib/primer/view_helper.rb
primer_view_components-0.0.101 app/lib/primer/view_helper.rb
primer_view_components-0.0.100 app/lib/primer/view_helper.rb
primer_view_components-0.0.99 app/lib/primer/view_helper.rb
primer_view_components-0.0.98 app/lib/primer/view_helper.rb
primer_view_components-0.0.97 app/lib/primer/view_helper.rb
primer_view_components-0.0.96 app/lib/primer/view_helper.rb
primer_view_components-0.0.95 app/lib/primer/view_helper.rb
primer_view_components-0.0.94 app/lib/primer/view_helper.rb
primer_view_components-0.0.93 app/lib/primer/view_helper.rb
primer_view_components-0.0.92 app/lib/primer/view_helper.rb
primer_view_components-0.0.91 app/lib/primer/view_helper.rb