Knockout Server-side Rendering
const domino = require("domino");
const html = `
<!DOCTYPE html>
<html>
<body>
<ul data-bind="foreach: list">
<li data-bind="text: $data"></>
</ul>
</body>
</html>
`;
const window = domino.createWindow(html);
const document = window.document;
global.document = document;
global.window = window;
const ko = require("knockout");
const viewModel = {
list: [
'John',
'Paul',
'George',
'Ringo'
]
};
const rootElement = document.documentElement;
ko.applyBindings(viewModel, rootElement);
console.log(rootElement.outerHTML);
no comments