I want to get an HTML string representation of my Maquette view in order to prerender it to a static html file. React has ReactDOMServer.renderToString. Is there a similar method for Maquette VNodes?
Asked
Active
Viewed 288 times
1 Answers
0
There is no equivalent for ReactDOMServer.renderToString
in maquette (yet).
We had an insightful discussion about it here.
The conclusions were that pre-rendered HTML should not include event-handlers and it should disable all inputs and buttons.
The maquette Projector
has a replace
method that is then safe to use to enhance the HTML.
Also take into account that in comparison to React, maquette is more lightweight.
So a server render might not even be necessary.

Rick Hoving
- 3,585
- 3
- 29
- 49
-
2The motivation for me is not necessarily to speed up time-to-first-meaningful-paint, but more to support clients that don't have JS enabled. Being able to display *something* when JS is turned off is one of the criteria defining a PWA. So it's fine if event-handlers aren't attached, but disabling form inputs is a bit excessive. If I build forms that can work without JS I don't want maquette disabling my buttons just because. – Jesse Hattabaugh Sep 23 '16 at 21:27