MyGit

v2.7.0

linkedin/dustjs

版本发布时间: 2015-04-18 07:56:01

linkedin/dustjs最新发布版本:v3.0.1(2021-12-30 02:22:21)

Supported Runtimes

With this release we are dropping official support for:

No explicit changes have been made to break Dust in these environments, but we will no longer run tests and may break them going forward.

Notable Changes

More flexible rendering

You can pass Dust body functions directly to dust.render and dust.stream, instead of the template name.

require(['lib/dust-core', 'views/index'], function(dust, index) {
  dust.render(index, context, function(err, out) { ... });
});

This means that you can also compile templates without having to name them-- just pass the compiled function directly to dust.render. You can decide if a function is eligible to be passed as a renderable by calling dust.isTemplateFn().

CommonJS templates

Dust can now compile templates into CommonJS modules. Set dust.config.cjs to true, or use the --cjs flag with dustc.

var dust = require('dustjs-linkedin'),
    index = require('views/index.js')(dust);

index.template; // contains the compiled template
index({ name: "Dust" }, function(err, out) { ... }); // use index to render or stream

Streams in context

You can include a ReadableStream directly in your Dust context and Dust will iterate over it like an array.

var resultStream = db.query("SELECT * FROM people").stream();

dust.renderSource("{#people}{firstName} {lastName}{/people}", { people: resultStream })
    .pipe(res);

As long as you stream the results instead of rendering, Dust will flush data from the Stream as it is output.

Caching

You can disable caching of templates (useful for development) by setting dust.config.cache = false. If caching is disabled, you must write a dust.onLoad function to tell Dust how to load partials, since it wouldn't be possible to load them in advance and cache them.

Errata

The exposed compiler options such as dust.optimizers are deprecated. They are now exposed under, e.g. dust.compiler.optimizers. In Dust 2.8.0 the old options will be removed.

dust.load, an undocumented but public function, has been made private. Consider using dust.onLoad to define special behavior to load a template.

Templates compiled with earlier Dust versions should be recompiled before using 2.7.0.

相关地址:原始地址 下载(tar) 下载(zip)

查看:2015-04-18发行的版本