Package Exports
- diffhtml-render-to-string
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (diffhtml-render-to-string) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
<±/> diffHTML Render to String
Stable Version: 1.0.0-beta.12
Use with diffHTML to render your Virtual Trees to strings. This is useful for
server-side rendering and testing. This works very similar to outerHTML and
will even accept all the same markup inputs as that API.
All middleware should work if it can run under Node.js. For instnace you can use React-like Components by importing from diffhtml-components.
Installation
npm install diffhtml-render-to-stringExample
import { html } from 'diffhtml';
import { renderToString } from 'diffhtml-render-to-string';
const markup = renderToString(html`
<div>Hello world</div>
`);
// Use with something like express to send to the client.
res.send(markup);Example components
import { html } from 'diffhtml';
import { Component } from 'diffhtml-components';
import { renderToString } from 'diffhtml-render-to-string';
class MyComponent extends Component {
render({ message }) {
return html`
<p>${message}</p>
`;
}
}
const markup = renderToString(html`
<${MyComponent} message="Hello world" />
`);
// Use with something like express to send to the client.
res.send(markup);