项目作者: dadi

项目描述 :
A Dust.js interface for DADI Web
高级语言: JavaScript
项目地址: git://github.com/dadi/web-dustjs.git
创建时间: 2017-05-05T10:53:56Z
项目社区:https://github.com/dadi/web-dustjs

开源协议:

下载


DADI Web

Dust.js engine interface

@dadi/web-dustjs"">npm (scoped)
Coverage Status
Build Status
JavaScript Style Guide
semantic-release

This module allows Dust.js templates to be used with DADI Web.

Installation

  • Add this module as a dependency:

    1. npm install @dadi/web-dustjs --save
  • Include it in the engines array passed to Web:

    1. require('@dadi/web')({
    2. engines: [
    3. require('@dadi/web-dustjs')
    4. ]
    5. })

Configuration

The following configuration parameters can be added to the global Web config file, under engines.dust.

cache

If true, compiled templates are saved to the Dust cache (recommended).

  • Format: Boolean
  • Default: true

debug

Dust.js debug mode enabled.

  • Format: Boolean
  • Default: false

debugLevel

The debug level to use. Should be one of DEBUG, INFO, WARN or ERROR.

  • Format: String
  • Default: ‘WARN’

whitespace

Preserve whitespace in the output.

  • Format: Boolean
  • Default: true

clientRender

enabled

If true, compiled templates are made available to the client-side.

  • Format: Boolean
  • Default: false

format

Defines whether compiled templates are written to individual JS files (‘separate’) or combined into a single one (‘combined’).

  • Format: [‘separate’, ‘combined’]
  • Default: ‘separate’

path

The location where compiled templates should be written to, relative to ‘public’. This should be a folder when ‘format’ is ‘separate’ and a file when ‘combined’.

  • Format: String
  • Default: 'templates'

whitelist

When defined, only templates with names matching an entry in whitelist will be made available to the client. Wildcards supported.

  • Format: Array
  • Default: []

paths

Paths required by Dust.

  • Format: Object
  • Default:
    1. {
    2. {
    3. filters: 'workspace/utils/filters',
    4. helpers: 'workspace/utils/helpers'
    5. }
    6. }

Helpers

This module automatically includes the official set of helpers by LinkedIn. Other helper modules will need to be required manually, using a loader file placed in the helpers directory defined in config (e.g. workspace/utils/helpers/loader.js)

Example:

  1. var components = require('@dadi/web').Components
  2. var dust = require('dustjs-linkedin')
  3. // Load common-dustjs-helpers
  4. var commonDustHelpers = require('common-dustjs-helpers')
  5. new commonDustHelpers.CommonDustjsHelpers().export_helpers_to(dust)
  6. // Load the DADI helper pack
  7. require('@dadi/dustjs-helpers')(dust, { components: components })