Sha256: 62e46b2da85d022fa35f4dc49dc524aa70ac0e654ac5750bb6bf09d802782cb8

Contents?: true

Size: 575 Bytes

Versions: 10

Compression:

Stored size: 575 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::Alpha::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

10 entries across 10 versions & 1 rubygems

Version Path
primer_view_components-0.0.114 app/lib/primer/view_helper.rb
primer_view_components-0.0.113 app/lib/primer/view_helper.rb
primer_view_components-0.0.112 app/lib/primer/view_helper.rb
primer_view_components-0.0.111 app/lib/primer/view_helper.rb
primer_view_components-0.0.110 app/lib/primer/view_helper.rb
primer_view_components-0.0.109 app/lib/primer/view_helper.rb
primer_view_components-0.0.108 app/lib/primer/view_helper.rb
primer_view_components-0.0.107 app/lib/primer/view_helper.rb
primer_view_components-0.0.106 app/lib/primer/view_helper.rb
primer_view_components-0.0.105 app/lib/primer/view_helper.rb