lr-server-renderer v1.0.0
lr-server-renderer reference
Server side renderer for lagoon road.
Information | - |
---|---|
Code coverage | |
Repo link | lr-server-renderer |
Dependencies | cheerio |
Size (ex. dependencies) | 612 bytes |
Version | 1.0.0 |
License | MIT |
Usage | guide |
renderer.template(html)
renderer.template('<html>...</html>');
Method sets the template for the output, all components will be added to this template
html:string
The template you want to use for the components and state that you might want to add.
renderer.render(html, placeholder)
renderer.render('<section>...</section>', '.placeholderName');
Adds a component to the template.
html:string
The components html that you want to load.
placeholder:string
A html selector that should be the parent of the html you want to add. The contents of the placeholder will be removed before adding the new html.
renderer.state(state)
renderer.state({ data : [...], otherProperties : true });
Add data to a script tag that you can access on the client again. This prevents loading the same data. The data will be available by accessing window.__state__
as json.
state:object
An object that has been loaded on the server that you want to transfer to the client.
renderer.html()
renderer.html();
Get the final output of the template and components that you have created, this data can be send back as the response to the client.
7 years ago