github.com/coveo/gotemplate@v2.7.7+incompatible/docs/doc_test/collections.rendered (about) 1 {% include navigation.html %} 2 {% raw %} 3 4 # Data collections (lists/slices and dicts/maps) 5 6 ## Maps 7 8 | Razor | Gotemplate | Note 9 | --- | --- | --- 10 | `` | `` | Creation 11 | `` | `` | Creation 12 | `` | `` | Update 13 | `` | `` | Update 14 | `` | `` | Merge (First dict has priority) 15 | `4` | `4` | Should be `4` 16 | `5` | `5` | Should be `5` 17 | `[1,4,null]` | `[1,4,null]` | Extract values, should be `[1,4,null]` 18 | `[1,3,4,5]` | `[1,3,4,5]` | Slice values, should be `[1,3,4,5]` 19 | `[5,4,3,1]` | `[5,4,3,1]` | Slice values, should be `[5,4,3,1]` 20 | `["test","test2","test3","test5"]` | `["test","test2","test3","test5"]` | Get keys, should be `["test","test2","test3","test5"]` 21 | `[1,3,4,5]` | `[1,3,4,5]` | Get values, should be `[1,3,4,5]` 22 23 ### Looping 24 25 #### Razor 26 27 ```go 28 test, 1, 1 29 test2, 3, 3 30 test3, 4, 4 31 test5, 5, 5 32 ``` 33 34 #### Gotemplate 35 36 ```go 37 test, 1, 1 38 test2, 3, 3 39 test3, 4, 4 40 test5, 5, 5 41 ``` 42 43 #### Result 44 45 ```go 46 test, 1, 1 47 test2, 3, 3 48 test3, 4, 4 49 test5, 5, 5 50 ``` 51 52 ## Slices 53 54 | Razor | Gotemplate | Note 55 | --- | --- | --- 56 | `` | `` | Creation 57 | `` | `` | Append 58 | `` | `` | Prepend 59 | `["test0","test1","test2","test3","test4"]` | `["test0","test1","test2","test3","test4"]` | Should be `["test0","test1","test2","test3","test4"]` 60 | `true` | `true` | Check if element is in list 61 | `true` | `true` | has is an alias to contains 62 | `true` | `true` | has Support inversion of argument if the first one is not a list 63 | `true` | `true` | has can also test for many elements 64 | `true` | `true` | List also support using methods 65 | `["test4","test3","test2","test1","test0"]` | `["test4","test3","test2","test1","test0"]` | Should be `["test4","test3","test2","test1","test0"]` 66 67 ### Looping 68 69 #### Razor 70 71 ```go 72 0, test0, test0 73 1, test1, test1 74 2, test2, test2 75 3, test3, test3 76 4, test4, test4 77 ``` 78 79 #### Gotemplate 80 81 ```go 82 0, test0, test0 83 1, test1, test1 84 2, test2, test2 85 3, test3, test3 86 4, test4, test4 87 ``` 88 89 #### Result 90 91 ```go 92 0, test0, test0 93 1, test1, test1 94 2, test2, test2 95 3, test3, test3 96 4, test4, test4 97 ``` 98 99 {% endraw %}