You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Tom Alexander 648ae5dfdb
Turns out I was wrong, the @size helper attempts to cast to a number regardless of the input and it uses that. Fixed the test.
4 years ago
..
README.md Added some notes about observed behavior and fixed return types for missing/absent keys. 4 years ago
inputarray.json Add tests and a Sizable trait for ContextElement. 4 years ago
inputemptystring.json Add tests and a Sizable trait for ContextElement. 4 years ago
inputfalse.json Add tests and a Sizable trait for ContextElement. 4 years ago
inputmissing.json Add tests and a Sizable trait for ContextElement. 4 years ago
inputnumber.json Add tests and a Sizable trait for ContextElement. 4 years ago
inputobject.json Added some notes about observed behavior and fixed return types for missing/absent keys. 4 years ago
inputstring.json Turns out I was wrong, the @size helper attempts to cast to a number regardless of the input and it uses that. Fixed the test. 4 years ago
inputtrue.json Add tests and a Sizable trait for ContextElement. 4 years ago
inputzero.json Add tests and a Sizable trait for ContextElement. 4 years ago
main.dust First attempt at fixing by reading all indirect references containing a reference to a single value as the original value is a failure. Turns out the @size helper treats numeric types in indirect references differently. 4 years ago

README.md

Excerpt from the DustJS tutorial:

Array - number of elements, [1,2,3,4] has size=4
String - length of the string, "abcdef" has size=6
Object - Number of properties in the object, {a:4, b:8, c:15, d:16} has size=4
Number - Value of the number, 23 has size 23 and 3.14 has size 3.14
Undefined, 0, empty string - zero
Any other value - length after conversion to string

This appears to be inaccurate (probably out of date because that tutorial was deprecated in favor of dustjs.com, but the latter is incomplete and lacking any reference to the @size helper.

Corrections

  • Booleans are 0, not converted to strings

Oddities

Reference parameters (like foo="{bar}") are usually treated as strings but it seems if it contains ONLY a reference to a value and not anything else, then it is still treated as a number.