Skip to content

Commit 6250389

Browse files
authored
Merge pull request #339 from metafacture/add_links_to_playground
Add links to playground for several fixes
2 parents ccd7b9a + ec0b2fe commit 6250389

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ Does nothing. It is used for benchmarking in Catmandu.
170170
nothing()
171171
```
172172

173+
[Example in Playground](https://metafacture.org/playground/?example=nothing)
174+
173175
##### `put_filemap`
174176

175177
Defines an external map for [lookup](#lookup) from a file or a URL. Maps with more than 2 columns are supported but are reduced to a defined key and a value column.
@@ -178,6 +180,8 @@ Defines an external map for [lookup](#lookup) from a file or a URL. Maps with mo
178180
put_filemap("<sourceFile>", "<mapName>", sep_char: "\t")
179181
```
180182

183+
[Example in Playground](https://metafacture.org/playground/?example=put_filemap)
184+
181185
The separator (`sep_char`) will vary depending on the source file, e.g.:
182186

183187
| Type | Separator |
@@ -207,6 +211,8 @@ put_map("<mapName>",
207211
)
208212
```
209213

214+
[Example in Playground](https://metafacture.org/playground/?example=put_map)
215+
210216
##### `put_rdfmap`
211217

212218
Defines an external RDF map for lookup from a file or an HTTP(S) resource.
@@ -218,6 +224,8 @@ put_rdfmap("<rdfResource>", "<rdfMapName>", target: "<rdfProperty>")
218224
put_rdfmap("<rdfResource>", "<rdfMapName>", target: "<rdfProperty>", select_language: "<rdfLanguageTag>")
219225
```
220226

227+
[Example in Playground](https://metafacture.org/playground/?example=put_rdfmap)
228+
221229
##### `put_var`
222230

223231
Defines a single global variable that can be referenced with `$[<variableName>]`.
@@ -226,6 +234,8 @@ Defines a single global variable that can be referenced with `$[<variableName>]`
226234
put_var("<variableName>", "<variableValue>")
227235
```
228236

237+
[Example in Playground](https://metafacture.org/playground/?example=put_var)
238+
229239
##### `put_vars`
230240

231241
Defines multiple global variables that can be referenced with `$[<variableName>]`.
@@ -237,6 +247,8 @@ put_vars(
237247
)
238248
```
239249

250+
[Example in Playground](https://metafacture.org/playground/?example=put_vars)
251+
240252
#### Record-level functions
241253

242254
##### `add_field`
@@ -247,6 +259,8 @@ Creates a field with a defined value.
247259
add_field("<targetFieldName>", "<fieldValue>")
248260
```
249261

262+
[Example in Playground](https://metafacture.org/playground/?example=add_field)
263+
250264
##### `array`
251265

252266
Converts a hash/object into an array.
@@ -281,6 +295,8 @@ end
281295
call_macro("<macroName>"[, <dynamicLocalVariables>...])
282296
```
283297

298+
[Example in Playground](https://metafacture.org/playground/?example=call_macro)
299+
284300
##### `copy_field`
285301

286302
Copies a field from an existing field.
@@ -289,6 +305,9 @@ Copies a field from an existing field.
289305
copy_field("<sourceField>", "<targetField>")
290306
```
291307

308+
[Example in Playground](https://metafacture.org/playground/?example=copy_field)
309+
310+
292311
##### `format`
293312

294313
Replaces the value with a formatted (`sprintf`-like) version.
@@ -321,6 +340,9 @@ Moves a field from an existing field. Can be used to rename a field.
321340
move_field("<sourceField>", "<targetField>")
322341
```
323342

343+
[Example in Playground](https://metafacture.org/playground/?example=move_field)
344+
345+
324346
##### `parse_text`
325347

326348
Parses a text into an array or hash of values.
@@ -352,6 +374,8 @@ paste("my.string", "~Hi", "a", "~how are you?")
352374
# "my.string": "Hi eeny how are you?"
353375
```
354376

377+
[Example in Playground](https://metafacture.org/playground/?example=paste)
378+
355379
##### `print_record`
356380

357381
Prints the current record as JSON either to standard output or to a file.
@@ -401,6 +425,8 @@ Removes a field.
401425
remove_field("<sourceField>")
402426
```
403427

428+
[Example in Playground](https://metafacture.org/playground/?example=remove_field)
429+
404430
##### `rename`
405431

406432
Replaces a regular expression pattern in subfield names of a field. Does not change the name of the source field itself.
@@ -409,6 +435,8 @@ Replaces a regular expression pattern in subfield names of a field. Does not cha
409435
rename("<sourceField>", "<regexp>", "<replacement>")
410436
```
411437

438+
[Example in Playground](https://metafacture.org/playground/?example=rename)
439+
412440
##### `retain`
413441

414442
Deletes all fields except the ones listed (incl. subfields).
@@ -417,6 +445,8 @@ Deletes all fields except the ones listed (incl. subfields).
417445
retain("<sourceField_1>"[, ...])
418446
```
419447

448+
[Example in Playground](https://metafacture.org/playground/?example=retain)
449+
420450
##### `set_array`
421451

422452
Creates a new array (with optional values).
@@ -426,6 +456,8 @@ set_array("<targetFieldName>")
426456
set_array("<targetFieldName>", "<value_1>"[, ...])
427457
```
428458

459+
[Example in Playground](https://metafacture.org/playground/?example=set_array)
460+
429461
##### `set_field`
430462

431463
Creates (or replaces) a field with a defined value.
@@ -465,6 +497,8 @@ Deletes empty fields, arrays and objects.
465497
vacuum()
466498
```
467499

500+
[Example in Playground](https://metafacture.org/playground/?example=vacuum)
501+
468502
#### Field-level functions
469503

470504
##### `append`
@@ -475,6 +509,8 @@ Adds a string at the end of a field value.
475509
append("<sourceField>", "<appendString>")
476510
```
477511

512+
[Example in Playground](https://metafacture.org/playground/?example=append)
513+
478514
##### `capitalize`
479515

480516
Upcases the first character in a field value.
@@ -483,6 +519,8 @@ Upcases the first character in a field value.
483519
capitalize("<sourceField>")
484520
```
485521

522+
[Example in Playground](https://metafacture.org/playground/?example=capitalize)
523+
486524
##### `count`
487525

488526
Counts the number of elements in an array or a hash and replaces the field value with this number.
@@ -499,6 +537,8 @@ Downcases all characters in a field value.
499537
downcase("<sourceField>")
500538
```
501539

540+
[Example in Playground](https://metafacture.org/playground/?example=downcase)
541+
502542
##### `filter`
503543

504544
Only keeps field values that match the regular expression pattern. Works only with array of strings/repeated fields.
@@ -515,6 +555,8 @@ Flattens a nested array field.
515555
flatten("<sourceField>")
516556
```
517557

558+
[Example in Playground](https://metafacture.org/playground/?example=flatten)
559+
518560
##### `from_json`
519561

520562
Replaces the string with its JSON deserialization.
@@ -549,6 +591,8 @@ Options:
549591
isbn("<sourceField>"[, to: "<isbnFormat>"][, verify_check_digit: "<boolean>"][, error_string: "<errorValue>"])
550592
```
551593

594+
[Example in Playground](https://metafacture.org/playground/?example=isbn)
595+
552596
##### `join_field`
553597

554598
Joins an array of strings into a single string.
@@ -557,6 +601,8 @@ Joins an array of strings into a single string.
557601
join_field("<sourceField>", "<separator>")
558602
```
559603

604+
[Example in Playground](https://metafacture.org/playground/?example=join_field)
605+
560606
##### `lookup`
561607

562608
Looks up matching values in a map and replaces the field value with this match. [External files](#put_filemap), [internal maps](#put_map) as well as [RDF resources](#put_rdfmap) can be used.
@@ -624,6 +670,8 @@ Adds a string at the beginning of a field value.
624670
prepend("<sourceField>", "<prependString>")
625671
```
626672

673+
[Example in Playground](https://metafacture.org/playground/?example=prepend)
674+
627675
##### `replace_all`
628676

629677
Replaces a regular expression pattern in field values with a replacement string. Regexp capturing is possible; refer to capturing groups by number (`$<number>`) or name (`${<name>}`).
@@ -632,6 +680,8 @@ Replaces a regular expression pattern in field values with a replacement string.
632680
replace_all("<sourceField>", "<regexp>", "<replacement>")
633681
```
634682

683+
[Example in Playground](https://metafacture.org/playground/?example=replace_all)
684+
635685
##### `reverse`
636686

637687
Reverses the character order of a string or the element order of an array.
@@ -650,6 +700,8 @@ sort_field("<sourceField>", reverse: "true")
650700
sort_field("<sourceField>", numeric: "true")
651701
```
652702

703+
[Example in Playground](https://metafacture.org/playground/?example=sort_field)
704+
653705
##### `split_field`
654706

655707
Splits a string into an array and replaces the field value with this array.
@@ -658,6 +710,8 @@ Splits a string into an array and replaces the field value with this array.
658710
split_field("<sourceField>", "<separator>")
659711
```
660712

713+
[Example in Playground](https://metafacture.org/playground/?example=split_field)
714+
661715
##### `substring`
662716

663717
Replaces a string with its substring as defined by the start position (offset) and length.
@@ -695,6 +749,8 @@ Deletes whitespace at the beginning and the end of a field value.
695749
trim("<sourceField>")
696750
```
697751

752+
[Example in Playground](https://metafacture.org/playground/?example=trim)
753+
698754
##### `uniq`
699755

700756
Deletes duplicate values in an array.
@@ -703,6 +759,9 @@ Deletes duplicate values in an array.
703759
uniq("<sourceField>")
704760
```
705761

762+
[Example in Playground](https://metafacture.org/playground/?example=uniq)
763+
764+
706765
##### `upcase`
707766

708767
Upcases all characters in a field value.
@@ -711,6 +770,8 @@ Upcases all characters in a field value.
711770
upcase("<sourceField>")
712771
```
713772

773+
[Example in Playground](https://metafacture.org/playground/?example=upcase)
774+
714775
##### `uri_encode`
715776

716777
Encodes a field value as URI. Aka percent-encoding.
@@ -742,6 +803,8 @@ if <condition>
742803
end
743804
```
744805

806+
[Example in Playground](https://metafacture.org/playground/?example=reject)
807+
745808
### Binds
746809

747810
#### `do list`
@@ -754,6 +817,8 @@ do list(path: "<sourceField>")
754817
end
755818
```
756819

820+
[Example in Playground](https://metafacture.org/playground/?example=do_list)
821+
757822
Only the current element is accessible in this case (as the root element).
758823

759824
When specifying a variable name for the current element, the record remains accessible as the root element and the current element is accessible through the variable name:
@@ -764,6 +829,8 @@ do list(path: "<sourceField>", "var": "<variableName>")
764829
end
765830
```
766831

832+
[Example in Playground](https://metafacture.org/playground/?example=do_list_with_var)
833+
767834
#### `do list_as`
768835

769836
Iterates over each _named_ element of an array (like [`do list`](#do-list) with a variable name). If multiple arrays are given, iterates over the _corresponding_ elements from each array (i.e., all elements with the same array index, skipping elements whose arrays have already been exhausted).
@@ -797,6 +864,8 @@ do once()
797864
end
798865
```
799866

867+
[Example in Playground](https://metafacture.org/playground/?example=do_once)
868+
800869
In order to execute multiple blocks only once, tag them with unique identifiers:
801870

802871
```perl
@@ -833,6 +902,8 @@ end
833902
call_macro("<macroName>"[, <dynamicLocalVariables>...])
834903
```
835904

905+
[Example in Playground](https://metafacture.org/playground/?example=do_put_macro)
906+
836907
### Conditionals
837908

838909
Conditionals start with `if` in case of affirming the condition or `unless` rejecting the condition.

0 commit comments

Comments
 (0)