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.90 app/lib/primer/view_helper.rb
primer_view_components-0.0.89 app/lib/primer/view_helper.rb
primer_view_components-0.0.88 app/lib/primer/view_helper.rb
primer_view_components-0.0.87 app/lib/primer/view_helper.rb
primer_view_components-0.0.86 app/lib/primer/view_helper.rb
primer_view_components-0.0.85 app/lib/primer/view_helper.rb
primer_view_components-0.0.84 app/lib/primer/view_helper.rb
primer_view_components-0.0.83 app/lib/primer/view_helper.rb
primer_view_components-0.0.82 app/lib/primer/view_helper.rb
primer_view_components-0.0.81 app/lib/primer/view_helper.rb
primer_view_components-0.0.80 app/lib/primer/view_helper.rb
primer_view_components-0.0.79 app/lib/primer/view_helper.rb
primer_view_components-0.0.78 app/lib/primer/view_helper.rb
primer_view_components-0.0.77 app/lib/primer/view_helper.rb
primer_view_components-0.0.76 app/lib/primer/view_helper.rb
primer_view_components-0.0.75 app/lib/primer/view_helper.rb
primer_view_components-0.0.74 app/lib/primer/view_helper.rb
primer_view_components-0.0.73 app/lib/primer/view_helper.rb
primer_view_components-0.0.72 app/lib/primer/view_helper.rb
primer_view_components-0.0.71 app/lib/primer/view_helper.rb