You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+71Lines changed: 71 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -170,6 +170,8 @@ Does nothing. It is used for benchmarking in Catmandu.
170
170
nothing()
171
171
```
172
172
173
+
[Example in Playground](https://metafacture.org/playground/?example=nothing)
174
+
173
175
##### `put_filemap`
174
176
175
177
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
[Example in Playground](https://metafacture.org/playground/?example=set_array)
460
+
429
461
##### `set_field`
430
462
431
463
Creates (or replaces) a field with a defined value.
@@ -465,6 +497,8 @@ Deletes empty fields, arrays and objects.
465
497
vacuum()
466
498
```
467
499
500
+
[Example in Playground](https://metafacture.org/playground/?example=vacuum)
501
+
468
502
#### Field-level functions
469
503
470
504
##### `append`
@@ -475,6 +509,8 @@ Adds a string at the end of a field value.
475
509
append("<sourceField>", "<appendString>")
476
510
```
477
511
512
+
[Example in Playground](https://metafacture.org/playground/?example=append)
513
+
478
514
##### `capitalize`
479
515
480
516
Upcases the first character in a field value.
@@ -483,6 +519,8 @@ Upcases the first character in a field value.
483
519
capitalize("<sourceField>")
484
520
```
485
521
522
+
[Example in Playground](https://metafacture.org/playground/?example=capitalize)
523
+
486
524
##### `count`
487
525
488
526
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.
499
537
downcase("<sourceField>")
500
538
```
501
539
540
+
[Example in Playground](https://metafacture.org/playground/?example=downcase)
541
+
502
542
##### `filter`
503
543
504
544
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.
515
555
flatten("<sourceField>")
516
556
```
517
557
558
+
[Example in Playground](https://metafacture.org/playground/?example=flatten)
559
+
518
560
##### `from_json`
519
561
520
562
Replaces the string with its JSON deserialization.
@@ -549,6 +591,8 @@ Options:
549
591
isbn("<sourceField>"[, to: "<isbnFormat>"][, verify_check_digit: "<boolean>"][, error_string: "<errorValue>"])
550
592
```
551
593
594
+
[Example in Playground](https://metafacture.org/playground/?example=isbn)
595
+
552
596
##### `join_field`
553
597
554
598
Joins an array of strings into a single string.
@@ -557,6 +601,8 @@ Joins an array of strings into a single string.
557
601
join_field("<sourceField>", "<separator>")
558
602
```
559
603
604
+
[Example in Playground](https://metafacture.org/playground/?example=join_field)
605
+
560
606
##### `lookup`
561
607
562
608
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.
624
670
prepend("<sourceField>", "<prependString>")
625
671
```
626
672
673
+
[Example in Playground](https://metafacture.org/playground/?example=prepend)
674
+
627
675
##### `replace_all`
628
676
629
677
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.
[Example in Playground](https://metafacture.org/playground/?example=sort_field)
704
+
653
705
##### `split_field`
654
706
655
707
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.
658
710
split_field("<sourceField>", "<separator>")
659
711
```
660
712
713
+
[Example in Playground](https://metafacture.org/playground/?example=split_field)
714
+
661
715
##### `substring`
662
716
663
717
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.
695
749
trim("<sourceField>")
696
750
```
697
751
752
+
[Example in Playground](https://metafacture.org/playground/?example=trim)
753
+
698
754
##### `uniq`
699
755
700
756
Deletes duplicate values in an array.
@@ -703,6 +759,9 @@ Deletes duplicate values in an array.
703
759
uniq("<sourceField>")
704
760
```
705
761
762
+
[Example in Playground](https://metafacture.org/playground/?example=uniq)
763
+
764
+
706
765
##### `upcase`
707
766
708
767
Upcases all characters in a field value.
@@ -711,6 +770,8 @@ Upcases all characters in a field value.
711
770
upcase("<sourceField>")
712
771
```
713
772
773
+
[Example in Playground](https://metafacture.org/playground/?example=upcase)
774
+
714
775
##### `uri_encode`
715
776
716
777
Encodes a field value as URI. Aka percent-encoding.
@@ -742,6 +803,8 @@ if <condition>
742
803
end
743
804
```
744
805
806
+
[Example in Playground](https://metafacture.org/playground/?example=reject)
807
+
745
808
### Binds
746
809
747
810
#### `do list`
@@ -754,6 +817,8 @@ do list(path: "<sourceField>")
754
817
end
755
818
```
756
819
820
+
[Example in Playground](https://metafacture.org/playground/?example=do_list)
821
+
757
822
Only the current element is accessible in this case (as the root element).
758
823
759
824
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>")
764
829
end
765
830
```
766
831
832
+
[Example in Playground](https://metafacture.org/playground/?example=do_list_with_var)
833
+
767
834
#### `do list_as`
768
835
769
836
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()
797
864
end
798
865
```
799
866
867
+
[Example in Playground](https://metafacture.org/playground/?example=do_once)
868
+
800
869
In order to execute multiple blocks only once, tag them with unique identifiers:
0 commit comments