Class: React::ServerRendering::PropshaftContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/react/server_rendering/propshaft_container.rb

Overview

Return asset contents by getting them from a Propshaft::Assembly instance.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.assemblyObject



8
9
10
# File 'lib/react/server_rendering/propshaft_container.rb', line 8

def assembly
  ::Rails.application.assets
end

.compatible?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/react/server_rendering/propshaft_container.rb', line 12

def compatible?
  !!defined?(Propshaft) && assembly.is_a?(Propshaft::Assembly)
end

Instance Method Details

#find_asset(path) ⇒ Object



17
18
19
# File 'lib/react/server_rendering/propshaft_container.rb', line 17

def find_asset(path)
  self.class.assembly.load_path.find(path).content.force_encoding("utf-8")
end