@@ -116,3 +116,114 @@ multi_multilingue:
116
116
en : ['dog', 'cat', 'bird']
117
117
fr : ['chien', 'chat', 'oiseau']
118
118
119
+ unknown_tag :
120
+ about :
121
+ title : ' Unknown tag'
122
+ definitions :
123
+ zAttribute :
124
+ initialValues : ' {
125
+ "type": "template",
126
+ "value": "{{ (file.getMetadata('' badTag'' ).value ?? '' whaat ?'' ) }}"
127
+ }'
128
+ metadata : ~
129
+ expected :
130
+ zAttribute : ' whaat ?'
131
+
132
+ first_metadata :
133
+ about :
134
+ title : ' First metadata set, with alternate value (1)'
135
+ description : ' for this test, only the metadata `IPTC:City` is set.'
136
+ definitions :
137
+ City :
138
+ initialValues : ' {
139
+ "type": "template",
140
+ "value": "{{ file.getMetadata('' XMP-iptcCore:CreatorCity'' ).value ?? file.getMetadata('' IPTC:City'' ).value ?? '' no-city ?'' }}"
141
+ }'
142
+ metadata :
143
+ ' IPTC:City ' : ' Paris'
144
+ expected :
145
+ City : ' Paris'
146
+
147
+ first_metadata_default :
148
+ about :
149
+ title : ' First metadata set, with alternate value (2)'
150
+ description : ' for this test, no metadata is set, so the default value is used.'
151
+ definitions :
152
+ City :
153
+ initialValues : ' {
154
+ "type": "template",
155
+ "value": "{{ file.getMetadata('' XMP-iptcCore:CreatorCity'' ).value ?? file.getMetadata('' IPTC:City'' ).value ?? '' no-city ?'' }}"
156
+ }'
157
+ metadata : ~
158
+ expected :
159
+ City : ' no-city ?'
160
+
161
+ many_metadata_to_mono :
162
+ about :
163
+ title : ' Many metadata to a mono-value attribute'
164
+ description : ' Here an array `[a, b]` is used, the `join` filter inserts a " - " only if required.'
165
+ definitions :
166
+ CreatorLocation :
167
+ initialValues : ' {
168
+ "type": "template",
169
+ "value": "{{ [file.getMetadata('' XMP-iptcCore:CreatorCity'' ).value, file.getMetadata('' XMP-iptcCore:CreatorCountry'' ).value] | join('' - '' ) }}"
170
+ }'
171
+ metadata :
172
+ ' XMP-iptcCore:CreatorCity ' : ' Paris'
173
+ ' XMP-iptcCore:CreatorCountry ' : ' France'
174
+ expected :
175
+ CreatorLocation : ' Paris - France'
176
+
177
+ many_metadata_to_multi :
178
+ about :
179
+ title : ' Many metadata to a multi-values attribute'
180
+ description : " _nb_: We fill an array that will be joined by `\\ n` to generate __one line per item__ (required).\n
181
+ \n
182
+ The `merge` filter __requires__ arrays, so `IPTC:Keywords` defaults to `[]` in case there is no keywords in metadata.\n "
183
+ definitions :
184
+ Keywords :
185
+ isMultiple : true
186
+ initialValues : ' {
187
+ "type": "template",
188
+ "value": "{{ ( (file.getMetadata('' IPTC:Keywords'' ).values ?? []) | merge([file.getMetadata('' IPTC:City'' ).value, file.getMetadata('' XMP-photoshop:Country'' ).value ]) ) | join('' \n'' ) }}"
189
+ }'
190
+ metadata :
191
+ ' IPTC:Keywords ' : ['Eiffel Tower', 'Seine river']
192
+ ' IPTC:City ' : ' Paris'
193
+ ' XMP-photoshop:Country ' : ' France'
194
+ expected :
195
+ Keywords : ['Eiffel Tower', 'Seine river', 'Paris', 'France']
196
+
197
+ code_to_string :
198
+ about :
199
+ title : ' Transform code to human readable text'
200
+ description : ' here the `ExposureProgram` metadata is a code (0...9), used to index an array of strings.'
201
+ definitions :
202
+ ExposureProgram :
203
+ initialValues : ' {
204
+ "type": "template",
205
+ "value": "{{ [
206
+ '' Not Defined'' , '' Manual'' , '' Program AE'' ,
207
+ '' Aperture-priority AE'' , '' Shutter speed priority AE'' ,
208
+ '' Creative (Slow speed)'' , '' Action (High speed)'' , '' Portrait'' ,
209
+ '' Landscape'' , '' Bulb''
210
+ ][file.getMetadata('' ExifIFD:ExposureProgram'' ).value]
211
+ ?? '' Unknown mode''
212
+ }}"
213
+ }'
214
+ metadata :
215
+ ' ExifIFD:ExposureProgram ' : 2
216
+ expected :
217
+ ExposureProgram : ' Program AE'
218
+
219
+ code_to_string_2 :
220
+ definitions :
221
+ ExposureProgram :
222
+ initialValues : ' {
223
+ "type": "template",
224
+ "value": "{{ [ '' a'' , '' b'' ][file.getMetadata('' ExifIFD:ExposureProgram'' ).value] ?? '' z'' }}"
225
+ }'
226
+ metadata : ~
227
+ expected :
228
+ ExposureProgram : ' z'
229
+
0 commit comments