Edit this topic

Content renderer

: request

: renderer

: content

: /modules/core/content/services/content-renderer.js

: https://github.com/DecentCMS/DecentCMS/blob/master/modules/core/content/services/content-renderer.js

ContentRenderer()

The ContentRenderer is responsible for the content item rendering lifecycle.

contentRenderer.promiseToRender(options)

Adds a shape or a content item to the list of shapes for the request.

Param Type Description
options
[options.id] string The id of an item to fetch and add as a shape.
[options.shape] object A shape to add to the list of shapes to render.
[options.displayType] string The display type to use when rendering the shape.

contentRenderer.render(context, pageBuilt)

Builds the rendered page from the list of shapes that was prepared so far. This method defines the rendering lifecycle, by emitting events and service calls:

  • 'placement-strategy'.placeShapes({shape, shapes, renderStream}, done)
  • 'shape-handler'.handle({shape, shapes, renderStream}, done)
  • decent.core.register-meta
  • decent.core.register-style
  • decent.core.register-script
  • 'rendering-strategy'.render({shape, shapes, renderStream}, done)
Param Type Description
context
[context.scope] object The scope, which is normally the current request.
[context.request] IncomingMessage The request.
[context.response] ServerResponse The response.
pageBuilt function The function to call when the page has been rendered.

ContentRenderer.registerMetaEvent

Calls for meta tag registering.

ContentRenderer.registerStyleEvent

Calls for style sheet registering.

ContentRenderer.registerScriptEvent

Calls for script registering.