Files
buuh/examples/server-rendering/view.js
T

26 lines
948 B
JavaScript
Raw Normal View History

2016-05-23 23:39:22 +09:00
const assert = require('assert')
2016-12-11 19:35:29 +01:00
const html = require('../../html')
2016-05-21 21:59:03 +09:00
2016-07-02 00:13:13 +02:00
module.exports = function (state, prev, send) {
2016-05-23 23:39:22 +09:00
const serverMessage = state.message.server
const clientMessage = state.message.client
assert.equal(typeof serverMessage, 'string', 'server should be a string')
2016-06-18 18:53:27 -06:00
assert.equal(typeof clientMessage, 'string', 'client should be a string')
2016-05-23 23:39:22 +09:00
2016-06-30 08:18:07 -07:00
return html`
2016-05-23 23:39:22 +09:00
<section id="app-root">
<h1>server message: ${serverMessage}</h1>
<h1>client message: ${clientMessage}</h1>
<p>${`
The first message is passed in by the server on compile time,
the second message was set by the client.
The more static the data you pass in, the more cachable your site
2016-06-23 11:34:27 +02:00
becomes (and thus performant). Try and keep the amount of properties
2016-05-23 23:39:22 +09:00
you pass in on the server to a minimum for most applications - it'll
make life a lot easier in the long run, hah.
`}</p>
2016-05-21 21:59:03 +09:00
</section>
`
}