class Wunderbar::Render
Constants
- RUBY2JS_OPTIONS
Public Class Methods
client(common, element, target)
click to toggle source
# File lib/wunderbar/react.rb, line 25 def self.client(common, element, target) "ReactDOM.render(#{common}, #{element})" end
eval(scripts, server)
click to toggle source
# File lib/wunderbar/react.rb, line 29 def self.eval(scripts, server) context = ExecJS.compile(scripts.compact.join(";\n")) context.eval(server) rescue ExecJS::ProgramError => e Wunderbar.error e "<pre>" + e.message.gsub('&', '&').gsub('<', '<').gsub('>', '>') + "</pre>" end
extract(nodes)
click to toggle source
return all nodes on server rendering, as there is no wrapper element like there is for vue
# File lib/wunderbar/react.rb, line 21 def self.extract(nodes) nodes end
nodejs()
click to toggle source
# File lib/wunderbar/vue.rb, line 12 def self.nodejs return @nodejs if @nodejs path = `which nodejs`.chomp path = `which node`.chomp if path.empty? raise RuntimeError.new('Unable to locate nodejs') if path.empty? @nodejs = path end
server(common)
click to toggle source
# File lib/wunderbar/react.rb, line 15 def self.server(common) "ReactDOMServer.renderToString(#{common})" end