Skip to content

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