|
| 1 | +The Mapper Node transforms data from one format to another. It is useful for converting data structures, changing data |
| 2 | +types, or applying custom transformations to the data. |
| 3 | + |
| 4 | +To achieve this, Templating languages are used to define the transformation rules. The Mapper Node supports both Liquid |
| 5 | +and, for simpler use cases, a custom-made templating language that merely supports replacing variables with their |
| 6 | +values. |
| 7 | + |
| 8 | +Since the two engines are totally different, they will be addressed separately. |
| 9 | + |
| 10 | +## Replace |
| 11 | + |
| 12 | +The Batch-inspired syntax allows replacing variable names with their values. The syntax is as follows: |
| 13 | + |
| 14 | +```text |
| 15 | +%variable% |
| 16 | +``` |
| 17 | + |
| 18 | +By using this, simple replacements can be made such as: |
| 19 | + |
| 20 | +```text |
| 21 | +This assignment is due on %due_date%. |
| 22 | +``` |
| 23 | + |
| 24 | +Accessing nested variables is also possible: |
| 25 | + |
| 26 | +```text |
| 27 | +This assignment is due on %course.assignment.due_date%. |
| 28 | +``` |
| 29 | + |
| 30 | +That's it, for all other use cases, Liquid should be used. Therefore, it is mainly useful when your data already has |
| 31 | +the correct data types, the names are simply incompatible. |
| 32 | + |
| 33 | +## Liquid |
| 34 | + |
| 35 | +The Shopify-developed engine is a powerful and flexible templating language that allows for complex data |
| 36 | +transformations. It supports loops, conditionals, filters, and more. \ |
| 37 | +The [Liqp](https://github.com/bkiers/Liqp) library provides the Liquid templating engine. Therefore, the behavior may |
| 38 | +not mimic the original Ruby-based Liquid engine perfectly. For the most part, it should work as expected though. |
| 39 | + |
| 40 | +As Liquid is a nicely documented language with a ton of features, please refer to the official documentation: |
| 41 | +https://shopify.github.io/liquid/basics/introduction/ |
| 42 | + |
| 43 | +Apart from the generic features, Snoty also provides some custom filters and tags: |
| 44 | + |
| 45 | +1. `unidiff` filter |
| 46 | + - This filter is used to convert a list of dictionaries into a unified diff format. It takes a list of dictionaries |
| 47 | + and returns a string representing the unified diff. |
| 48 | + - Example: |
| 49 | + ```liquid |
| 50 | + {% assign diff = diff.change.description.old | unidiff diff.change.description.new %} |
| 51 | + ``` |
| 52 | +
|
| 53 | +## Examples |
| 54 | +### List all changes |
| 55 | +````liquid |
| 56 | +## WebUntis-Änderung! |
| 57 | +
|
| 58 | +{% for diff in diff.change %} |
| 59 | +- Change: {{ diff[0] }} |
| 60 | + ```json |
| 61 | + {{ diff[1] | json }} |
| 62 | + ``` |
| 63 | +{% endfor %} |
| 64 | +```` |
0 commit comments