MCPcopy
hub / github.com/flosch/pongo2 / Len

Method Len

value.go:270–281  ·  view source on GitHub ↗

Len returns the length for an array, chan, map, slice or string. Otherwise it will return 0.

()

Source from the content-addressed store, hash-verified

268// Len returns the length for an array, chan, map, slice or string.
269// Otherwise it will return 0.
270func (v *Value) Len() int {
271 switch v.getResolvedValue().Kind() {
272 case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice:
273 return v.getResolvedValue().Len()
274 case reflect.String:
275 runes := []rune(v.getResolvedValue().String())
276 return len(runes)
277 default:
278 logf("Value.Len() not available for type: %s\n", v.getResolvedValue().Kind().String())
279 return 0
280 }
281}
282
283// Slice slices an array, slice or string. Otherwise it will
284// return an empty []int.

Callers 15

IndexMethod · 0.95
resolveMethod · 0.95
IsTrueMethod · 0.45
NegateMethod · 0.45
ContainsMethod · 0.45
IterateOrderMethod · 0.45
filterLengthFunction · 0.45
filterLengthisFunction · 0.45
filterFirstFunction · 0.45
filterJoinFunction · 0.45
filterLastFunction · 0.45
filterCapfirstFunction · 0.45

Calls 3

getResolvedValueMethod · 0.95
logfFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected