Add tests and a Sizable trait for ContextElement.
parent
76193bf806
commit
1a54e35736
@ -0,0 +1,9 @@
|
||||
Excerpt from [the DustJS tutorial](https://github.com/linkedin/dustjs/wiki/Dust-Tutorial#size_keyxxx___size_helper_Available_in_Dust_V11_release):
|
||||
|
||||
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
|
||||
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"val": [
|
||||
"Alice",
|
||||
"Bob",
|
||||
"Chris"
|
||||
]
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"val": ""
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"val": false
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"notval": "Alice"
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"val": 7.21
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"val": {
|
||||
"pet": "cat",
|
||||
"name": "fluffy"
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"val": "Alice"
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"val": true
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"val": 0
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
The size of val ({val|js|s}) is {@size key=val /}{~n}
|
||||
The size of "{val}" is {@size key="{val}" /}{~n}
|
||||
The size with no key is {@size /}{~n}
|
Loading…
Reference in New Issue