Skip to main content

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 }}
BytesFormatted
123456789123.46 MB
10241.02 KB
94564534549.46 GB
56563785.66 MB
2344354565675623.44 TB