Last active
July 13, 2016 00:21
-
-
Save jasonmit/2460b43c445273e26b91d35b04ef9ffa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Fastboot from 'fastboot'; | |
| export default middleware(req, res, next) { | |
| const fb = new FastBoot({ distPath: distPath}); | |
| res.render('foo-bar', function(err, layoutHtml) { | |
| const $layout = cheerio.load(layoutHtml); | |
| fb.visit(req.url).then((result) => { | |
| const app = result.instance; | |
| const html = result.html(); | |
| const wormhole = app.lookup('service:wormhole'); | |
| get(wormhole, 'holes').forEach((hole) => { | |
| $layout.find('#' + get(hole, 'to')).append(get(hole, 'html')); | |
| }); | |
| // todo: also append the ember app! | |
| }); | |
| }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default Service.extend({ | |
| holes: computed(function() { | |
| return Ember.A(); | |
| }), | |
| register(hole) { | |
| get(this, 'holes').pushObject({ | |
| html: hole.$().html(), // <- I'm sure line won't work | |
| to: get(hole, 'to') | |
| }); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default Component.extend({ | |
| wormhole: inject.service(), | |
| _appendToDestination() { | |
| const ret = this._super(...arguments); | |
| if (typeof FastBoot !== 'undefined') { | |
| get(this, 'wormhole').register(this); | |
| } | |
| return ret; | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment