Releases: linkedin/dustjs
v3.0.1
v3.0.0
What's Changed
- Bump deps by @sethkinast in #734
- Prioritize resolution of .then by @brianmhunt in #736
- Don't use instanceof to determine if a Context is a Context by @sethkinast in #744
- place location provided by peg 0.9 onto the AST by @jimmyhchan in #706
- {?exists} and {^exists} now supports values from a promise by @samuelms1 in #753
- Decrease security vulnerabilities by upgrading cli dependency (#754 #748) by @danactive in #756
- fix: Security bug about prototype pollution by @sumeetkakkar in #805
New Contributors
- @brianmhunt made their first contribution in #736
- @samuelms1 made their first contribution in #753
- @danactive made their first contribution in #756
- @sumeetkakkar made their first contribution in #805
Full Changelog: v2.7.2...v3.0.0
v2.7.2
Notable Changes
Filters
Dust filter functions previously took one argument, the string to filter. They now accept a second argument, which is the current context
.
Helpers
Dust helpers can now return primitives.
Helpers act like references or sections depending on if they have a body. When they have no body, they act like a reference and look in params.filters
for filters to use. When they have a body, they act like a section. You can return thenables and streams normally.
{@return value="" filters="|s" /}
{@return value=""}{.} World{/return}
v2.7.1
Notable Changes
dust.config.cache
In previous versions, setting dust.config.cache
to false
would blow away the entire cache on every render. Now, setting it to false
just prevents new templates from being added and cached templates from being used. Setting it back to true
means that previously-cached templates will be ready to use.
dust.onLoad
We have added a callback(null, compiledTemplate)
signature to dust.onLoad
.
Calling the onLoad
callback with a compiled template function will use this template to satisfy the load request. The template is not automatically registered under any name when passed to the callback, so the onLoad
function should handle registration as it needs.
You can still call the callback with uncompiled template source and Dust will compile and store it, while respecting your dust.config.cache
setting.
dust.makeBase
dust.makeBase
is now aliased to dust.context
.
Errata
Dust 2.7.0 broke backwards compatibility with older Dust compilers. This regression has been fixed so templates compiled with older versions of Dust will continue to work with Dust 2.7.1; you can use an older compiler if needed.
v2.7.0
Supported Runtimes
With this release we are dropping official support for:
- Internet Explorer 7
- Node.js 0.8
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.
v2.6.2
Notable Changes
- Dust contexts can now contain Promises. The Promise will be evaluated once it resolves or rejects.
dustc --watch
now reruns the compilation when a watched template changes- Added new methods to the Context public API:
Context#clone
,Context#pop
, andContext#resolve
.- More info: http://www.dustjs.com/docs/helper-api/
v2.6.1
This release fixes two small issues:
- Compiling templates with empty blocks such as
{<foo}{/foo}
leaked compiler data into the template. - Negative numbers can be passed as parameters, e.g. {#foo a=-1 b=-2.3 /}
v2.6.0
Major changes in this version:
Dust now supports being included as an AMD module, and allows templates to be compiled as AMD modules for inclusion. More information: https://github.com/linkedin/dustjs/wiki/Loading-Dust-via-AMD-(require.js)
A new dustc
command-line compiler that acts like a shell script, with support for input/output redirection. dustc
can also operate on an entire directory of files at once and concatenate the output to a single file.
v2.5.1
- #522 Fix the use of a multi-level object key (e.g. foo.bar) as the key for an index lookup inside non-self-closing tags. (@sethkinast)
v2.5.0
- #515 Remove the warning log when you attach a new Stream event (@sethkinast)
- #513 Treat compiled body functions as blocks to render instead of functions to evaluate. Dust body functions are now flagged with .___dustBody to differentiate them from functions set in the context. (@sethkinast)
- #511 Treat formats and buffers as interchangeable when they are mixed together in order to prevent stack overflows with large templates and add a whitespace flag to dust.config (@sethkinast)
- #504 Update README formatting (@NickStefan)
- #503 Update contributors list (@sethkinast)
- #502 Don't use the regexp constructor since we are using a regexp literal anyway (@jimmyhchan)