Class: ViewComponent::Template::File

Inherits:
ViewComponent::Template show all
Defined in:
lib/view_component/template.rb

Instance Attribute Summary

Attributes inherited from ViewComponent::Template

#details, #path

Instance Method Summary collapse

Methods inherited from ViewComponent::Template

#call_method_name, #compile_to_component, #default_format?, #inline_call?, #normalized_variant_name, #requires_compiled_superclass?, #safe_method_name, #safe_method_name_call

Constructor Details

#initialize(component:, details:, path:) ⇒ File

Returns a new instance of File.



23
24
25
26
27
28
29
30
# File 'lib/view_component/template.rb', line 23

def initialize(component:, details:, path:)
  super(
    component: component,
    details: details,
    path: path,
    lineno: 0
  )
end

Instance Method Details

#sourceObject

Load file each time we look up #source in case the file has been modified



37
38
39
# File 'lib/view_component/template.rb', line 37

def source
  ::File.read(@path)
end

#typeObject



32
33
34
# File 'lib/view_component/template.rb', line 32

def type
  :file
end