Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Rendering your content on the server brings a few benefits:
Since this is a Ruby framework and you can run Ruby on the server pretty easily (I've heard there were a few Ruby backend frameworks for this), I thought server rendering would be pretty easy, but given that this diff is only around 300 lines as of this PR submission (and most of them are the list of HTML tags), this is a whole lot easier than I imagined.
A couple things I wanted to discuss before this gets merged are:
I'll update this issue as I think of more discussion points.
Just following up here. I've rebased this branch on the current
I'm still trying to come up with a way to make the router something better than a copy/paste job from the client-side code to the server side. That seems to be the last thing that's absolutely necessary to making this workable. What does everyone think of this?
location = if RUBY_ENGINE == 'opal' Bowser.window.location else # This doesn't exist yet, but it'd just be an object with methods to match `Bowser.location`. Clearwater::Router.location(request.path) end # Store in a constant so it's available outside this file Router = Clearwater::Router.new(location: location) do # ... end
The idea is to find a way that the router code can be executed on both the server and the client. So an app would probably do something like
The only thing that differs between the two would be how we figure out the current location. For both Rails and Roda (the two frameworks I've tested this branch with), this is done with
Actually, now that I think about it, it probably just needs to respond to
I just realized when I tried the above example that it doesn't work because
require 'components/subcomponent' module Routing module_function def create_router location=Bowser.window.location Clearwater::Router.new(location: location) do route 'foo' => Subcomponent.new('Foo') route 'bar' => Subcomponent.new('Bar') end end end
I put this file in