Edit this topic

Dust view engine

: shell

: dust-view-engine

: view-engine

: /modules/core/ui/services/dust-view-engine.js

: https://github.com/DecentCMS/DecentCMS/blob/master/modules/core/ui/services/dust-view-engine.js

Functions

DustViewEngine()

A view engine using Dust templates. http://akdubya.github.io/dustjs/ https://github.com/linkedin/dustjs/wiki/Dust-Tutorial

The view engine exposes by default the standard helpers: https://github.com/linkedin/dustjs-helpers

Helpers

T - Makes the enclosed string localizable.

    {@t}Text to localize{/t}

Shape

It adds a 'shape' helper that enables the rendering of DecentCMS shapes. The shape helper takes a 'shape' parameter that should point to the shape object to render. Optional parameters are tag and class.

    {@shape shape=footer tag="footer" class="main-footer"/}

Style

Registers a style sheet. Use the non-minimized name, without extension, as the name parameter.

    {@style name="style"/}

Styles

Renders the list of registered styles.

    {@styles/}

Script

Registers a script. Use the non-minimized name, without extension, as the name parameter.

    {@script name="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.js"/}

Scripts

Renders the list of registered scripts.

    {@scripts/}

Meta

Registers a meta tag. name: the name of the tag value: the value of the tag (rendered as the content attribute) Additional attributes will be rendered as-is.

{@meta name="generator" value="DecentCMS"/}

Metas

Renders registered meta tags.

    {@metas/}

Date

Formats a date using the Luxon library. value: the date to format. format: the format string to use (see https://moment.github.io/luxon/docs/manual/formatting.html for reference).

     {@date format/}

Dump

A filter to pretty-print an object, skipping its 'temp' property. This is particularly useful to dump the current content and debug templates.

     {meta|dump|s}
     {.|dump|s}

Note: you may need to install Node with full ICU support, in order to format with locales other than 'en-US'.

Plain

A filter that removes tags and newlines from an HTML source

     {body.html|plain}
load(templatePath, done)function

Loads the rendering function from the provided path.

DustViewEngine()

A view engine using Dust templates. http://akdubya.github.io/dustjs/ https://github.com/linkedin/dustjs/wiki/Dust-Tutorial

The view engine exposes by default the standard helpers: https://github.com/linkedin/dustjs-helpers

Helpers

T - Makes the enclosed string localizable.

    {@t}Text to localize{/t}

Shape

It adds a 'shape' helper that enables the rendering of DecentCMS shapes. The shape helper takes a 'shape' parameter that should point to the shape object to render. Optional parameters are tag and class.

    {@shape shape=footer tag="footer" class="main-footer"/}

Style

Registers a style sheet. Use the non-minimized name, without extension, as the name parameter.

    {@style name="style"/}

Styles

Renders the list of registered styles.

    {@styles/}

Script

Registers a script. Use the non-minimized name, without extension, as the name parameter.

    {@script name="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.js"/}

Scripts

Renders the list of registered scripts.

    {@scripts/}

Meta

Registers a meta tag. name: the name of the tag value: the value of the tag (rendered as the content attribute) Additional attributes will be rendered as-is.

{@meta name="generator" value="DecentCMS"/}

Metas

Renders registered meta tags.

    {@metas/}

Date

Formats a date using the Luxon library. value: the date to format. format: the format string to use (see https://moment.github.io/luxon/docs/manual/formatting.html for reference).

     {@date format/}

Dump

A filter to pretty-print an object, skipping its 'temp' property. This is particularly useful to dump the current content and debug templates.

     {meta|dump|s}
     {.|dump|s}

Note: you may need to install Node with full ICU support, in order to format with locales other than 'en-US'.

Plain

A filter that removes tags and newlines from an HTML source

     {body.html|plain}

Kind: global function

load(templatePath, done) ⇒ function

Loads the rendering function from the provided path.

Kind: global function
Returns: function - The template function.

Param Type Description
templatePath string The path to the .dust file.
done function The callback function to call when the template is loaded.