@motorcycle/mostly-html
Version:
Server-side rendering for Motorcycle.ts
23 lines • 848 B
JavaScript
import { hold, map } from '@motorcycle/stream';
import { HtmlDomSource } from './HtmlDomSource';
import { toHtml } from 'mostly-html';
/**
* Renders mostly-dom VNodes into HTML for server-side rendering.
* @name Html<A = Element, B = Event>(sinks: HtmlSinks): HtmlSources<A, B>
* @example
* import { run } from '@motorcycle/run'
* import { Html, HtmlSources, HtmlSinks } from '@motorcycle/mostly-html'
* import { UI } from './UI'
* import { observe } from '@motorcycle/stream'
*
* const { sources: { html$ } } = run<HtmlSources, HtmlSinks>(UI, Html)
*
* observe((html: string) => { /* Do something with html *\/ }, html$)
*/
export function Html(sinks) {
var view$ = sinks.view$;
var html$ = hold(map(toHtml, view$));
var dom = new HtmlDomSource([]);
return { dom: dom, html$: html$ };
}
//# sourceMappingURL=Html.js.map