Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed deprecation warning for default filter #567

Merged
merged 1 commit into from
Oct 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -761,9 +761,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 @@ -760,9 +760,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