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

Allow filters to be used to set default values when a key is falsy #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xonecas
Copy link

@xonecas xonecas commented Jun 27, 2011

Commit msg:

Modified the return value of Context.reference to allow filters to be used to set default values

Reason

When working with JSON api responses sometimes a section of the data structure might be empty and undefined, by default dust will not render anything for these missing keys, so this changes allows for the use of filters to fill in the blanks. Lets say we have a data structure of statistics, some stats are n/a so they are undefined. Using a filters like so:

    dust.filters.num = function (value) {
       return value || "0";
    }

We can make sure that the undefined numerical values come up as 0s or any other default value desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants