Skip to content

Deprecated Features

Seth Kinast edited this page Mar 26, 2015 · 5 revisions

Deprecation warnings in the Dust logs link here. You can find information on what features are deprecated, along with suggestions for how to replace those features in your Dust templates.

{@tap}

Deprecated in: 1.6.2

Removed in: 1.8.0

Deprecated because: Starting in Dust 2.6.2, use Context#resolve to do the same thing.

Alternatives: For code that looked like this:

evaluatedVal = dust.helpers.tap(val, chunk, context);

Replace with:

evaluatedVal = context.resolve(val);

{@default}

Deprecated in: 1.6.0

Removed in: 1.7.0

Deprecated because: {@default} has been replaced by {@none}, which has the same semantics. There are some slight differences, which are enhancements:

  • {@default} had to be the last thing in your {@select}, but {@none} can appear anywhere in the block, even before your truth tests.
  • The block stopped rendering after {@default} was reached, but you can have as many {@none} helpers as you want.

Alternatives: You can replace {@default} with {@none} directly.

{@if}

Deprecated in: 1.5.0

Removed in: 1.6.0

Deprecated because: {@if} uses eval() internally, which greatly impacts both the speed at which your template can be rendered as well as the security of your application. In addition, using this helper allows template authors to inject considerable amounts of logic into their template, which goes against the philosophy of Dust.

Alternatives: You can replace many {@if} statements with the comparison helpers {@eq}, {@lt}, and {@gt}. These helpers can also be nested to check multiple conditions. For more complex comparisons, move the logic from your template to a context helper-- a function contained in your Dust context.

{@if cond="{x} < {y} && {b} == {c}"}The system is down{/if}
{! replace with: !}
{@lt key=x value=y}
  {@eq key=b value=c}
    The system is down
  {/eq}
{/lt}

{@if cond="{x} && ('{y}'.length < {z})"}The system is down{/if}
{! replace with: !}
{#systemDown}The system is down{/systemDown}
{! in your context: !}
{
  "systemDown": function(chunk, context) {
    var x = context.get('x'),
        y = context.get('y'),
        z = context.get('z');
    return (x && y.length < z);
  },
  ...
}

{@idx}

Deprecated in: 1.5.0

Removed in: 1.6.0

Deprecated because: this helper function has been replaced by a Dust built-in grammar feature.

Alternatives: Replace uses of this helper with {$idx}. This feature does not require dustjs-helpers at all.

{#list}
  {@idx/}. {.}
{/list}
{! replace with !}
{#list}
  {$idx}. {.}
{/list}
Clone this wiki locally