Sha256: 29d62fc796fde43a049e2878f66d4d0533e4fe3c1073817ecafa2792830ec418
Contents?: true
Size: 826 Bytes
Versions: 108
Compression:
Stored size: 826 Bytes
Contents
# frozen_string_literal: true module Primer # Conditionally renders a `Primer::BaseComponent` around the given content. If the given condition # is true, a `Primer::BaseComponent` will render around the content. If the condition is false, only # the content is rendered. class ConditionalWrapper < Primer::Component # @param condition [Boolean] Whether or not to wrap the content in a `Primer::BaseComponent`. # @param base_component_arguments [Hash] The arguments to pass to `Primer::BaseComponent`. def initialize(condition:, **base_component_arguments) @condition = condition @base_component_arguments = base_component_arguments end def call return content unless @condition BaseComponent.new(**@base_component_arguments).render_in(self) { content } end end end
Version data entries
108 entries across 108 versions & 2 rubygems