Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: Store mount selector and return this #625

Merged
merged 3 commits into from
Feb 13, 2018
Merged

Conversation

goto-bus-stop
Copy link
Member

This allows .mount('body') to be used on the server like so:

module.exports = app.mount('body')

Then, when server rendering you can do:

var app = require('./app')
fillServerTemplate(html, app.selector, app.toString('/'))

Where fillServerTemplate is a function that replaces the HTML at a
CSS selector with some string.

This way you do not need to check for typeof window in your
application entry point to do server rendering, and it allows tools like
bankai to automatically inline server rendered html in the correct place.

This allows `.mount('body')` to be used on the server like so:

```js
module.exports = app.mount('body')
```

Then, when server rendering you can do:

```js
var app = require('./app')
fillServerTemplate(html, app.selector, app.toString('/'))
```

Where `fillServerTemplate` is a function that replaces the HTML at a
CSS selector with some string.

This way you do not need to check for `typeof window` in your
application entry point to do server rendering, and it allows tools like
bankai to automatically inline server rendered html in the correct place.
Copy link
Member

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yoshuawuyts
Copy link
Member

Probably also needs a docs update tho

@goto-bus-stop
Copy link
Member Author

good call, can you check if the words make sense too?

@goto-bus-stop goto-bus-stop merged commit a23dc51 into master Feb 13, 2018
@goto-bus-stop goto-bus-stop deleted the ssr-mount branch February 13, 2018 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants