nxus / renderer

A rendering framework for Nxus applications.
0 stars 0 forks source link

nxus-renderer

Build Status

A rendering framework for Nxus applications.

Installation

In your Nxus application:

> npm install nxus-renderer --save

Usage

Defining a renderer

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.

Rendering a string

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)});

Rendering a file

app.get('renderer').renderFile(type, filename).then((renderedText) => {});

You can pass an optional arugment opts for options to pass to the renderer.

API


Renderer

Renderer renders different files and content using common rendering engines, like EJS and MarkDown.

render

Request rendered content based on type

Parameters

Returns Promise The rendered content

renderer

Provide a renderer for a particular type (file extension)

Parameters

renderFile

Provide a renderer for a particular type (file extension)

Parameters

Returns Promise The rendered content