Sha256: c82aaff4ddf618b6a390c84b767f2226b596c0287e8415ff150a4c6c0d0c50dc
Contents?: true
Size: 1.26 KB
Versions: 4
Compression:
Stored size: 1.26 KB
Contents
module Lookbook # Represents the component or view template partial # that is being rendered in a preview. # # @ignore methods # @api public class RenderableEntity < Entity include LocatableEntity def initialize(identifier) @identifier = identifier @base_directories = Engine.component_paths @file_path = PathUtils.determine_full_path(component? ? "#{name}.rb" : identifier, @base_directories) unless @file_path && File.exist?(@file_path) raise LookbookError, "The render target #{@identifier} was not found." end @lookup_path = PathUtils.to_lookup_path(relative_file_path) end def component_class @identifier.constantize if component? end def name component? ? component_class.name.underscore : @identifier end def template_file_path component? ? Dir.glob("#{directory_path}/#{file_name(true)}.*.erb").first : file_path end def inline? component? ? template_file_path.present? : false end def component? @identifier.first.upcase == @identifier.first && !@identifier.include?(".") && !@identifier.include?("/") end def template? !component? end def type component? ? :component : :template end end end
Version data entries
4 entries across 4 versions & 1 rubygems