5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/react/router/rails/view_helper.rb', line 5
def react_router(routes, location = 'HashLocation', args = {}, options = {}, &block)
options = {:tag => options} if options.is_a?(Symbol)
if options[:prerender_location]
fail "Server rendering doesn't work with HashLocation" if location == 'HashLocation'
block = Proc.new do
concat React::Router::Renderer.render(routes, options[:prerender_location], args)
end
end
html_options = options.reverse_merge(:data => {})
html_options[:data].tap do |data|
data[:'react-router-class'] = routes
data[:'react-router-location'] = location
end
html_tag = html_options[:tag] || :div
html_options.except!(:tag, :prerender_location)
content_tag(html_tag, '', html_options, &block)
end
|