Skip to content

Commit

Permalink
Merge pull request #567 from kaylynb/RemoveDefaultDeprecationWarning
Browse files Browse the repository at this point in the history
Removed deprecation warning for default filter
  • Loading branch information
carljm committed Oct 29, 2015
2 parents 5b6adc2 + bfa31f2 commit f5ab716
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog
master (unreleased)
-------------------

* Remove deprecation warning when using the `default` filter without specifying a third argument. Merge of
[#567](https://github.com/mozilla/nunjucks/pull/567).
* Add support for chaining of addGlobal, addFilter, etc. Thanks Rob Graeber. Merge of
[#537](https://github.com/mozilla/nunjucks/pull/537)
* Fix error propagation. Thanks Tom Delmas. Merge of
Expand Down
4 changes: 1 addition & 3 deletions docs/fr/templating.md
Original file line number Diff line number Diff line change
Expand Up @@ -767,9 +767,7 @@ Si `value` est strictement `undefined`, cela retourne `default`, sinon
Auparavant, il agissait comme si `boolean` était à true par défaut et donc toute
valeur fausse retournait `default`. Dans la 2.0, le comportement par défaut retourne
`default` seulement pour une valeur `undefined`. Vous pouvez obtenir l'ancien
comportement en passant `true` à `boolean`, ou en utilisant simplement `value or default`.
La 2.0 affichera un avertissement si `boolean` n'est pas passé, mais nous allons supprimer
cet avertissement dans la prochaine version.**
comportement en passant `true` à `boolean`, ou en utilisant simplement `value or default`.**

### sort(arr, reverse, caseSens, attr)

Expand Down
4 changes: 1 addition & 3 deletions docs/templating.md
Original file line number Diff line number Diff line change
Expand Up @@ -766,9 +766,7 @@ If `value` is strictly `undefined`, return `default`, otherwise
filter. Previously, it acted as if `boolean` was true by default,
and any falsy value would return `default`. In 2.0 the default is
only an `undefined` value returns `default`. You can get the old
behavior by passing `true` to `boolean`, or just use `value or default`.
2.0 will show a warning if `boolean` is not passed, but we will remove
this warning in the next version.**
behavior by passing `true` to `boolean`, or just use `value or default`.**

### sort(arr, reverse, caseSens, attr)

Expand Down
14 changes: 0 additions & 14 deletions src/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ function normalize(value, defaultValue) {
return value;
}

var hasWarnedDefault = false;

var filters = {
abs: function(n) {
return Math.abs(n);
Expand Down Expand Up @@ -65,18 +63,6 @@ var filters = {
},

'default': function(val, def, bool) {
if(bool !== true && bool !== false && !hasWarnedDefault) {
hasWarnedDefault = true;
console.log(
'[nunjucks] Warning: the "default" filter was used without ' +
'specifying the type of comparison. 2.0 changed the default ' +
'behavior from boolean (val ? val : def) to strictly undefined, ' +
'so you should make sure that doesn\'t break anything. ' +
'Be explicit about this to make this warning go away, or wait until 2.1. ' +
'See http://mozilla.github.io/nunjucks/templating.html#defaultvalue-default-boolean'
);
}

if(bool) {
return val ? val : def;
}
Expand Down

0 comments on commit f5ab716

Please sign in to comment.