Sha256: 9780326527fa5fd8881604f262e4f674934976041548b2202f56a87c74e4add8
Contents?: true
Size: 1 KB
Versions: 3
Compression:
Stored size: 1 KB
Contents
module ReactiveRuby module ServerRendering class ContextualRenderer < React::ServerRendering::SprocketsRenderer def initialize(options = {}) super(options) ComponentLoader.new(v8_context).load end def render(component_name, props, prerender_options) if prerender_options.is_a? Hash if v8_runtime? && prerender_options[:context_initializer] raise React::ServerRendering::PrerenderError.new(component_name, props, "you must use 'therubyracer' with the prerender[:context] option") unless v8_runtime? else prerender_options[:context_initializer].call v8_context prerender_options = prerender_options[:static] ? :static : true end end super(component_name, props, prerender_options) end private def v8_runtime? ExecJS.runtime.name == "(V8)" end def v8_context @v8_context ||= @context.instance_variable_get("@v8_context") end end end end
Version data entries
3 entries across 3 versions & 1 rubygems