Edit this topic

Render stream

: request

: render-stream

: /modules/core/ui/services/render-stream.js

: https://github.com/DecentCMS/DecentCMS/blob/master/modules/core/ui/services/render-stream.js

class: RenderStream

new RenderStream(scope, options)

A transform stream for rendering shapes.

Param Type Description
scope object The scope
options object The options
[options.scripts] Array The list of scripts
[options.stylesheets] Array The list of stylesheets
[options.meta] object The meta tags
[options.title] string The title
[options.tags] Array The stack of tags currently open

renderStream.write

Writes a string, unencoded.

Param Type Description
text string The text to write.

renderStream.writeEncoded

Writes the string after HTML-encoding it.

Param Type Description
text string The string to write.

renderStream.writeLine

Writes the string, followed by \r\n.

Param Type Description
[text] string The string to write.

renderStream.writeEncodedLine

Writes the string after HTML-encoding it, followed by \r\n.

Param Type Description
[text] string The string to write.

renderStream.br

Renders a <br/> tag.

renderStream.tag

Renders a tag.

Param Type Description
tagName string The name of the tag.
[attributes] object Attributes to add to the tag.
[content] string Text content of the tag.

renderStream.renderAttributes

Renders attributes as name="encoded value".

Param Type Description
attributes object The attributes to render.

renderStream.startTag

Writes the a start tag, and pushes the tag on a stack in order for endTag to know what tag to close.

Param Type Description
tagName string The name of the tag.
[attributes] object The attributes of the tag.

renderStream.endTag

Writes the end tag for the latest unclosed tag started.

renderStream.endAllTags

Closes all pending tags.

renderStream.shape

Triggers the rendering of the provided shape.

Param Type Description
[options] object The options object.
[options.shape] object The shape to render.
[options.tag] string An optional tag name to enclose the shape in if it exists.
[options.attributes] object An optional list of attributes to add to the enclosing tag.
[options.shapeName] string An optional name for the shape that overrides shape.meta.type.

renderStream.doctype

Renders a doctype tag.

Param Type Description
[type] string The doctype. 'html' if not specified.

renderStream.addStyleSheet

Adds a style sheet to the list of style sheets. The style sheet name will resolve to a file in the theme, or in modules, under a css folder.

Param Type Description
name string The name of a local style sheet file.

renderStream.addExternalStyleSheet

Adds an external style sheet to the list of style sheets.

Param Type Description
url string The URL of an external style sheet file.

renderStream.renderStyleSheets

Renders all style sheets that have been registered so far using addStyleSheet and addExternalStyleSheet.

renderStream.addScript

Adds a script to the list of scripts. The script name will resolve to a file in the theme, or in modules, under a js folder.

Param Type Description
name string The name of a local script file.

renderStream.addExternalScript

Adds an external script to the list of scripts.

Param Type Description
url string The URL of an external script file.

renderStream.renderScripts

Renders all scripts that have been registered so far using addScript and addExternalScript.

renderStream.addMeta

Adds a meta tag. This does not render the tag, it just stores the data for, typically, the layout template to render using renderMeta.

Param Type Description
name string The name of the meta tag (will be rendered as the name attribute).
value string The value of the meta tag (will be rendered as the content attribute).
[attributes] object Additional attributes to add to the meta tag.

renderStream.renderMeta

Renders the meta tag that have been registered so far using addMeta.