Asynchronous templates for the browser and node.js

Dust by LinkedIn


Build Status

Asynchronous templates for the browser and node.js

View project onGitHub

Dust Highlights!

  • async/streaming operation
  • browser/node compatibility
  • extended Mustache/ctemplate syntax
  • clean, low-level API
  • high performance
  • composable templates

This is the LinkedIn fork of Dust

Details in the blog post : Leaving jsps in the Dust

We chose Dust after evaluating a bunch of others. Read more here : Dust for client templates at LinkedIn

We built one of our high volume app Profile using dust and we heavily focus on performance. Here is the Velocity tech talk The Curious case of Dust.js and performance

We will gradually be extending this library with core feature enhancements, helper functions and bug fixes.

Dust Quick Tutorial

Learn how to use LinkedIn fork of Dust

Dust core features - Code examples

Learn by playing with the dust templates

Dust helpers - Code examples

Learn how to use the helpers

Dust With Express/Node

Get started with using dust with express in node.js

LinkedIn additions include:

Release 2.2.3

  • PR-363, GH-340 - Remove old optimization to avoid looking at arrays in get.

Release 2.2.2

  • PR-368 - Add context.getTemplateName. This method now correctly returns the template name even for directly loaded templates being used as partials. For end users please use this api for getting the template name instead of ctx.templatename.

Release 2.2.0

  • PR-360 - Use get for all Dust references.

Release 2.1.0

  • PR-350 - Support dynamic template names for the context's template name.
  • PR-347, GH-137 - Improve JS debugging support for dust

Release 2.0.3

  • PR-323, GH-322 - dynamic blocks {+"{dynam}"} has been corrected. It was adding the data twice.
  • GH-328 - move template name from global to the context

Release 2.0.2, (2.0.1)

  • 2.0.1.add line and column numbers in to the parser so we can use it in linters or debuggers
  • 2.0.2 actually uses it when using dust.parse

Release 2.0.0

Core Enhancements
Bug fixes
PR-289, fix the CacheVM context across `dust.loadSource` calls for node.js

Release 1.2.3

Perf Improvements for IE7
  • PR-253: performance enhancement in IE7

Release 1.2.2

Bug fixes
  • GH-245: solve incorrect error line reported in pegjs
  • GH-241: using dust.isArray in place of Array.isArray

Release 1.2.1

Bug fixes
  • GH-220 - Reverted in V1.2.1 because of functional issues it introduced

Release 1.2.0

Core enhancements
  • GH- 166 - Added trimming of white spaces in dust templates configuration in the dust.compile ( default option is still true)
Bug fixes/ perf improvements
  • GH-148 - Fix the array reference access with $idx
  • GH-187 - Whitespace grammar rule for partial is now consistent with ther tags
  • GH-203 - Doc updated
  • GH-212 - jam support for dust
  • GH-216 - Add missing semicolon to help with minify
  • GH-220 - Reverted in V1.2.1
  • GH-222 - Fix regression add back $idx within a nested object in an array
Test enhancements
  • Tests's description updated to be more descriptive.
  • Bug fixes and UI improved.
  • Tests grouped by category

Release 1.1.0

Core enhancements
  • Extend the #section block to support $idx and $len for lists of primitives
  • Add support for assigning multiple event-listeners on stream
Bug fixes/ perf improvements
  • Fix the #section block on how it behaves with empty arrays. Maintain consistency between ?, # and ^ for truthy/falsy evaluations
  • Fix "this" value in anonymous functions passed into the context object
  • Handle undefined filters and helpers gracefully
Extensions and helpers
  • Helpers are now in its own node package See here
  • @math for simple math operations such as add/subtract/mod/ceil etc. It also supports branching based on the output of math operation
  • @size helper for determining the size of lists/objects/primitives
  • @contextDump helper for debugging the current context in the dust stack

NOTE: We have removed dust helpers code from the dustjs-linkedin repo from V1.1.1, use npm install dustjs-helpers instead for using the helpers

Release 1.0.0

Core enhancements
  • Extend partials to support inline params like #sections
  • Section index for lists of objects,$idx in the context
  • Section size/length for lists of objects, $len in the context
  • Extend grammar to relax whitespace/eol for certain Dust tags
  • Support numbers in the inline params
  • Extend core support for accessing single dimensional array with [] notation
  • Support dynamic blocks, similar to dynamic partials
  • Add pipe support for Node.js
  • Add support for runnin on V8/rhino
  • Extend filters for JSON.stringify and JSON.parse
  • Jasmine for unit tests
  • Travis CI for continuos build and Cover for code coverage report
Bug fixes/ perf improvements
  • Fix to support > node0.4
  • Fix to peg.js to print the line and column number for syntax errors in dust templates
  • Improved compile times by 10X by optimizing the way we used the peg parser
Extensions and helpers
  • Simple logic/branching helpers with @select/ @eq/ @lt etc
  • Versatile @if helper relies on the eval for complex expression evaluation, Here are the perf results for eval http://jsperf.com/dust-if. Use with caution, since eval is known to be slow.


For LinkedIn Dust

          $ npm install dustjs-linkedin 

For LinkedIn Dust helpers

          $ npm install dustjs-helpers 

To render compiled templates in the browser:

          <script src="dust-core.min.js"></script> 

To compile a template on the command line, use the dustc command. Its syntax is:

          dustc [{-n|--name}=<template_name>] {inputfilename|-} [<outputfilename>] 

For example, to compile a template on the command line and have it registered under the same name as the source file:

          $ dustc template.html 

You can customize the name under which the template is registered:

          $ dustc --name=mytemplate template.html 

Running Tests

To run tests:

          $ grunt test 

To run tests on your client browser:

          $ grunt testClient 

Coverage report

Code coverage is generated when we run our tests

          $ grunt test 

To view HTML test coverage report:

          $ open tmp/coverage/index.html

Dust.js Code Coverage Report

Guidelines - Contributing to LinkedIn Dust

If you are interested in contributing to Dust, please read our contributing guideline


Download .zip file Download .tar.gz file

Dust is maintained by linkedin.

This page was generated by GitHub Pages using the Architect theme by Jason Long.