Sha256: d4f50d7bf7d28466a38ba6527467e5e570782ff858e36bc0a93a182bd6d72988

Contents?: true

Size: 571 Bytes

Versions: 39

Compression:

Stored size: 571 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::HeadingComponent",
      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

39 entries across 39 versions & 1 rubygems

Version Path
primer_view_components-0.0.70 app/lib/primer/view_helper.rb
primer_view_components-0.0.69 app/lib/primer/view_helper.rb
primer_view_components-0.0.68 app/lib/primer/view_helper.rb
primer_view_components-0.0.67 app/lib/primer/view_helper.rb
primer_view_components-0.0.66 app/lib/primer/view_helper.rb
primer_view_components-0.0.65 app/lib/primer/view_helper.rb
primer_view_components-0.0.64 app/lib/primer/view_helper.rb
primer_view_components-0.0.63 app/lib/primer/view_helper.rb
primer_view_components-0.0.62 app/lib/primer/view_helper.rb
primer_view_components-0.0.61 app/lib/primer/view_helper.rb
primer_view_components-0.0.60 app/lib/primer/view_helper.rb
primer_view_components-0.0.59 app/lib/primer/view_helper.rb
primer_view_components-0.0.58 app/lib/primer/view_helper.rb
primer_view_components-0.0.57 app/lib/primer/view_helper.rb
primer_view_components-0.0.56 app/lib/primer/view_helper.rb
primer_view_components-0.0.55 app/lib/primer/view_helper.rb
primer_view_components-0.0.54 app/lib/primer/view_helper.rb
primer_view_components-0.0.53 app/lib/primer/view_helper.rb
primer_view_components-0.0.52 app/lib/primer/view_helper.rb