github.com/coveo/gotemplate@v2.7.7+incompatible/docs/doc_test/data.rendered (about) 1 {% include navigation.html %} 2 {% raw %} 3 # Data manipulation 4 5 Using a data file with the following content in a format that doesn't follow a standard. 6 ```!Data 7 IntegerValue = 1 8 FloatValue = 1.23 9 StringValue = "Foo bar" 10 EquationResult = 46658 11 ListValue = ["value1", "value2"] 12 DictValue = {"key1": "value1", "key2": "value2"} 13 ``` 14 15 ## toYaml 16 17 | Razor | Gotemplate 18 | --- | --- 19 | ```DictValue: 20 key1: value1 21 key2: value2 22 EquationResult: 46658 23 FloatValue: 1.23 24 IntegerValue: 1 25 ListValue: 26 - value1 27 - value2 28 StringValue: Foo bar 29 ``` | ```DictValue: 30 key1: value1 31 key2: value2 32 EquationResult: 46658 33 FloatValue: 1.23 34 IntegerValue: 1 35 ListValue: 36 - value1 37 - value2 38 StringValue: Foo bar 39 ``` 40 41 ``` 42 DictValue: 43 key1: value1 44 key2: value2 45 EquationResult: 46658 46 FloatValue: 1.23 47 IntegerValue: 1 48 ListValue: 49 - value1 50 - value2 51 StringValue: Foo bar 52 ``` 53 54 ## toJson 55 56 | Razor | Gotemplate 57 | --- | --- 58 | ```{ 59 "DictValue": { 60 "key1": "value1", 61 "key2": "value2" 62 }, 63 "EquationResult": 46658, 64 "FloatValue": 1.23, 65 "IntegerValue": 1, 66 "ListValue": [ 67 "value1", 68 "value2" 69 ], 70 "StringValue": "Foo bar" 71 }``` | ```{ 72 "DictValue": { 73 "key1": "value1", 74 "key2": "value2" 75 }, 76 "EquationResult": 46658, 77 "FloatValue": 1.23, 78 "IntegerValue": 1, 79 "ListValue": [ 80 "value1", 81 "value2" 82 ], 83 "StringValue": "Foo bar" 84 }``` 85 86 ``` 87 { 88 "DictValue": { 89 "key1": "value1", 90 "key2": "value2" 91 }, 92 "EquationResult": 46658, 93 "FloatValue": 1.23, 94 "IntegerValue": 1, 95 "ListValue": [ 96 "value1", 97 "value2" 98 ], 99 "StringValue": "Foo bar" 100 } 101 ``` 102 103 ## toHcl 104 105 | Razor | Gotemplate 106 | --- | --- 107 | ```EquationResult = 46658 108 FloatValue = 1.23 109 IntegerValue = 1 110 ListValue = ["value1", "value2"] 111 StringValue = "Foo bar" 112 113 DictValue { 114 key1 = "value1" 115 key2 = "value2" 116 }``` | ```EquationResult = 46658 117 FloatValue = 1.23 118 IntegerValue = 1 119 ListValue = ["value1", "value2"] 120 StringValue = "Foo bar" 121 122 DictValue { 123 key1 = "value1" 124 key2 = "value2" 125 }``` 126 127 ``` 128 EquationResult = 46658 129 FloatValue = 1.23 130 IntegerValue = 1 131 ListValue = ["value1", "value2"] 132 StringValue = "Foo bar" 133 134 DictValue { 135 key1 = "value1" 136 key2 = "value2" 137 } 138 ``` 139 140 ## Nested conversions 141 142 This test shows how you can convert from and to other formats. 143 144 | Razor | Gotemplate 145 | --- | --- 146 | ```EquationResult = 46658 147 FloatValue = 1.23 148 IntegerValue = 1 149 ListValue = ["value1", "value2"] 150 StringValue = "Foo bar" 151 152 DictValue { 153 key1 = "value1" 154 key2 = "value2" 155 }``` | ```EquationResult = 46658 156 FloatValue = 1.23 157 IntegerValue = 1 158 ListValue = ["value1", "value2"] 159 StringValue = "Foo bar" 160 161 DictValue { 162 key1 = "value1" 163 key2 = "value2" 164 }``` 165 166 ``` 167 EquationResult = 46658 168 FloatValue = 1.23 169 IntegerValue = 1 170 ListValue = ["value1", "value2"] 171 StringValue = "Foo bar" 172 173 DictValue { 174 key1 = "value1" 175 key2 = "value2" 176 } 177 ``` 178 179 180 ## Merging data structures 181 182 This test shows how you can merge data structures 183 184 ``` 185 186 # Gives precedence to the first dictionary 187 value1 string == value1 string 188 value2 string == value2 string 189 value3 string == value3 string 190 true bool == true bool 191 false bool == false bool 192 true bool == true bool 193 ``` 194 {% endraw %}