Templates
FileFlows utilizes the Scriban templating engine.
Syntax Overview
Scriban offers a robust syntax for template manipulation. Here are some key components:
Variables
Variables are denoted by enclosing them in double curly braces. For example:
{{ variable_name }}
Control Structures
Control structures like loops and conditionals are supported in Scriban. They follow a similar syntax to other programming languages:
{{ if condition }}
// code block
{{ end }}
{{ for item in collection }}
// code block
{{ end }}
Example Usage
Here's a simple example demonstrating how to use Scriban within FileFlows:
{{ difference = file.Size - file.Orig.Size }}
{{ percent = (difference / file.Orig.Size) * 100 | math.round 2 }}
Input File: {{ file.Orig.FullName }}
Output File: {{ file.FullName }}
Original Size: {{ file.Orig.Size | file_size }}
Final Size: {{ file.Size | file_size }}
{{- if difference < 0 }}
File grew in size: {{ difference | math.abs | file_size }}
{{ else }}
File shrunk in size by: {{ difference | file_size }} / {{ percent }}%
{{ end }}
Resources
For further information and detailed documentation on Scriban syntax and features, refer to the official Scriban Documentation.
Custom Functions
FileFlows has added some custom functions to make formatting messages easier.
file_size
This function formats a number with up to two decimal places and the largest unit.
{{ file.Size | file_size }}
Bytes | Formatted |
---|---|
123456789 | 123.46 MB |
1024 | 1.02 KB |
9456453454 | 9.46 GB |
5656378 | 5.66 MB |
23443545656756 | 23.44 TB |