Class: ViewComponent::Template::File
- Inherits:
-
Template
- Object
- Template
- ViewComponent::Template::File
- Defined in:
- lib/view_component/template.rb
Instance Method Summary collapse
-
#initialize(component:, details:, path:) ⇒ File
constructor
A new instance of File.
-
#source ⇒ Object
Load file each time we look up #source in case the file has been modified.
- #type ⇒ Object
Constructor Details
#initialize(component:, details:, path:) ⇒ File
Returns a new instance of File.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/view_component/template.rb', line 23 def initialize(component:, details:, path:) # If the template file has no format (e.g. .erb instead of .html.erb), # assume the default format (html). if details.format.nil? Kernel.warn("WARNING: Template format for #{path} is missing, defaulting to :html.") details = ActionView::TemplateDetails.new(details.locale, details.handler, DEFAULT_FORMAT, details.variant) end super end |
Instance Method Details
#source ⇒ Object
Load file each time we look up #source in case the file has been modified
39 40 41 |
# File 'lib/view_component/template.rb', line 39 def source ::File.read(@path) end |
#type ⇒ Object
34 35 36 |
# File 'lib/view_component/template.rb', line 34 def type :file end |