Sha256: 18f2eb57f668999da28ab3e83242aa5a9a43977e23c184aa5e7c5819250e04c0
Contents?: true
Size: 1.38 KB
Versions: 5
Compression:
Stored size: 1.38 KB
Contents
# frozen_string_literal: true module Primer module Forms # :nodoc: class BaseComponent include Primer::ClassNameHelper extend ActsAsComponent def self.compile! base_path = Utils.const_source_location(self.name) unless base_path warn "Could not identify the template for #{base}" return end dir = File.dirname(base_path) renders_template File.join(dir, "#{self.name.demodulize.underscore}.html.erb"), :render_template super end delegate :required?, :disabled?, :hidden?, to: :@input def perform_render(&block) return "" unless render? @__prf_content_block = block compile_and_render_template end def content return @__prf_content if defined?(@__prf_content_evaluated) && @__prf_content_evaluated @__prf_content_evaluated = true @__prf_content = capture do @__prf_content_block.call end end # :nocov: def type :component end # :nocov: def input? false end def to_component self end def render? true end private def compile_and_render_template self.class.compile! unless self.class.instance_methods(false).include?(:render_template) render_template end end end end
Version data entries
5 entries across 5 versions & 2 rubygems