1.0.0-beta.18 • Published 4 years ago
diffhtml-render-to-string v1.0.0-beta.18
<±/> diffHTML Render to String
Stable Version: 1.0.0-beta.18
Allows you to render diffHTML markup to string. This is useful for server-side rendering, compiling to static HTML, and testing.
All middleware should work if it can run under Node.js. For instance you can use Components by importing from diffhtml-components or get logging by importing diffhtml-middleware-logger.
Installation
npm install diffhtml-render-to-string
Example
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);
1.0.0-beta.18
4 years ago
1.0.0-beta.17
4 years ago
1.0.0-beta.16
4 years ago
1.0.0-beta.15
4 years ago
1.0.0-beta.14
4 years ago
1.0.0-beta.13
4 years ago
1.0.0-beta.12
4 years ago
1.0.0-beta.11
4 years ago
1.0.0-beta.9
7 years ago
1.0.0-beta.8
7 years ago
1.0.0-beta.7
7 years ago
1.0.0-beta.6
7 years ago
1.0.0-beta.5
7 years ago
1.0.0-beta.4
7 years ago
1.0.0-beta.3
7 years ago
1.0.0-beta.2
7 years ago
1.0.0-beta.1
7 years ago
1.0.0-beta
7 years ago