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
RenderStream
Kind: global class
- RenderStream
- new RenderStream(scope, options)
- .write
- .writeEncoded
- .writeLine
- .writeEncodedLine
- .br
- .tag
- .renderAttributes
- .startTag
- .endTag
- .endAllTags
- .shape
- .zone
- .doctype
- .addStyleSheet
- .addExternalStyleSheet
- .renderStyleSheets
- .addScript
- .addExternalScript
- .renderScripts
- .addMeta
- .renderMeta
- .addLink
- .renderLinks
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.links] | Array |
The list of links |
| [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.
Kind: instance property of RenderStream
| Param | Type | Description |
|---|---|---|
| text | string |
The text to write. |
renderStream.writeEncoded
Writes the string after HTML-encoding it.
Kind: instance property of RenderStream
| Param | Type | Description |
|---|---|---|
| text | string |
The string to write. |
renderStream.writeLine
Writes the string, followed by \r\n.
Kind: instance property of RenderStream
| Param | Type | Description |
|---|---|---|
| [text] | string |
The string to write. |
renderStream.writeEncodedLine
Writes the string after HTML-encoding it, followed by \r\n.
Kind: instance property of RenderStream
| Param | Type | Description |
|---|---|---|
| [text] | string |
The string to write. |
renderStream.br
Renders a <br/> tag.
Kind: instance property of RenderStream
renderStream.tag
Renders a tag.
Kind: instance property of RenderStream
| 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".
Kind: instance property of RenderStream
| 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.
Kind: instance property of RenderStream
| 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.
Kind: instance property of RenderStream
renderStream.endAllTags
Closes all pending tags.
Kind: instance property of RenderStream
renderStream.shape
Triggers the rendering of the provided shape.
Kind: instance property of RenderStream
| 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.zone
Triggers the rendering of the provided zone.
Kind: instance property of RenderStream
| Param | Type | Description |
|---|---|---|
| [options] | object |
The options object. |
| [options.shape] | object |
The parent shape of the zone to render. |
| [options.zone] | string |
The name of the zone to render. |
| [options.tag] | string |
An optional tag name to enclose the zone in if it exists. |
| [options.attributes] | object |
An optional list of attributes to add to the enclosing tag. |
renderStream.doctype
Renders a doctype tag.
Kind: instance property of RenderStream
| 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.
Kind: instance property of RenderStream
| 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.
Kind: instance property of RenderStream
| 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.
Kind: instance property of RenderStream
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.
Kind: instance property of RenderStream
| Param | Type | Description |
|---|---|---|
| name | string |
The name of a local script file. |
renderStream.addExternalScript
Adds an external script to the list of scripts.
Kind: instance property of RenderStream
| 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.
Kind: instance property of RenderStream
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.
Kind: instance property of RenderStream
| 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.
Kind: instance property of RenderStream
renderStream.addLink
Adds a link tag. This does not render the tag, it just stores the data for, typically, the layout template to render using renderLinks.
Kind: instance property of RenderStream
| Param | Type | Description |
|---|---|---|
| rel | string |
The relationship of the linked resource to the current page (will be rendered as the rel attribute). |
| type | string |
The MIME type of the link tag (will be rendered as the type attribute). |
| href | string |
The URL of the link tag (will be rendered as the content attribute). |
| [attributes] | object |
Additional attributes to add to the link tag. |
renderStream.renderLinks
Renders the link tags that have been registered so far using addLink.
Kind: instance property of RenderStream