A rendering framework for Nxus applications.
In your Nxus application:
> npm install nxus-renderer --save
app.get('renderer').renderer(type, handler);
Where type
is usually the filename extension and handler
returns the rendered text when called with contents to render and an optional opts
object.
app.get('renderer').render(type, text).then((renderedText) => {console.log(renderedText)});
You can pass an optional arugment opts
for options to pass to the renderer.
app.get('renderer').render(type, text, {title: 'My Title'}).then((renderedText) => {console.log(renderedText)});
app.get('renderer').renderFile(type, filename).then((renderedText) => {});
You can pass an optional arugment opts
for options to pass to the renderer.
Renderer renders different files and content using common rendering engines, like EJS and MarkDown.
Request rendered content based on type
Parameters
type
string The type (e.g. 'html') of the contentcontent
string The contents to renderopts
object=(default {}) Options for the renderer contextReturns Promise The rendered content
Provide a renderer for a particular type (file extension)
Parameters
type
string The type (e.g. 'html') this renderer should handlehandler
function Function to receive (content, options) and return rendered contentProvide a renderer for a particular type (file extension)
Parameters
Returns Promise The rendered content