Sha256: df1f26e87c9be391627bb4b3b49f67342169f91d456ef0ac62578ab168362022

Contents?: true

Size: 528 Bytes

Versions: 141

Compression:

Stored size: 528 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::Beta::Octicon",
      heading: "Primer::Beta::Heading",
      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

141 entries across 141 versions & 2 rubygems

Version Path
primer_view_components-0.36.5 app/lib/primer/view_helper.rb
openproject-primer_view_components-0.52.2 app/lib/primer/view_helper.rb
primer_view_components-0.36.4 app/lib/primer/view_helper.rb
openproject-primer_view_components-0.52.1 app/lib/primer/view_helper.rb
openproject-primer_view_components-0.52.0 app/lib/primer/view_helper.rb
primer_view_components-0.36.3 app/lib/primer/view_helper.rb
openproject-primer_view_components-0.51.0 app/lib/primer/view_helper.rb
primer_view_components-0.36.2 app/lib/primer/view_helper.rb
openproject-primer_view_components-0.50.1 app/lib/primer/view_helper.rb
openproject-primer_view_components-0.50.0 app/lib/primer/view_helper.rb
primer_view_components-0.36.1 app/lib/primer/view_helper.rb
primer_view_components-0.36.0 app/lib/primer/view_helper.rb
openproject-primer_view_components-0.49.2 app/lib/primer/view_helper.rb
primer_view_components-0.35.2 app/lib/primer/view_helper.rb
openproject-primer_view_components-0.49.1 app/lib/primer/view_helper.rb
openproject-primer_view_components-0.49.0 app/lib/primer/view_helper.rb
primer_view_components-0.35.1 app/lib/primer/view_helper.rb
primer_view_components-0.35.0 app/lib/primer/view_helper.rb
openproject-primer_view_components-0.48.2 app/lib/primer/view_helper.rb
openproject-primer_view_components-0.48.1 app/lib/primer/view_helper.rb