Clean Templates Tool
CleanTemplates is a standalone command-line tool that prepares existing Fluent templates for use with the current version of the Fluent engine. It is primarily used when upgrading from an older version of Fluent.
Requirements
- Windows
- .NET Framework 4.8
- Microsoft Office (Word) — required only if processing
.rtfor Word XML (.xml) templates
Usage
CleanTemplates.exe [options] [datasources] <template_file(s)> <output_directory>
Both <template_file(s)> and <output_directory> are required and must be the last two arguments, in that order.
<template_file(s)> accepts a single file path or a wildcard pattern (e.g., C:\templates\*.docx).
The <output_directory> must already exist. CleanTemplates will not create it.
The output file cannot be the same as the input file. CleanTemplates will not overwrite the original template.
Always make a back up copy of your templates before using this tool.
Supported template formats
| Extension | Format |
|---|---|
.docx, .dotx | Word Open XML |
.docm, .dotm | Word Open XML (macro-enabled) |
.xlsx | Excel Open XML |
.xlsm | Excel Open XML (macro-enabled) |
.pptx | PowerPoint Open XML |
.rtf | Rich Text Format (converted to .docx via Word — requires Office) |
.xml | Word XML document (converted to .docx via Word — requires Office) |
Options
Options must appear before <template_file(s)> and <output_directory>.
Parameter mode
Controls how datasource parameters are represented in the cleaned template. Only one parameter mode can be active at a time.
| Flag | Description | Default |
|---|---|---|
-pp | Parameter Plus — parameters are written as ${name} with surrounding quotes preserved | ✅ Yes |
-po | Parameter Only — parameters are written as ${name} with no additional formatting | |
-ps | Substitution — parameters are written in substitution syntax |
Tag style
Controls how Fluent tags are represented in the cleaned template. Only one tag style can be active at a time.
| Flag | Description | Default |
|---|---|---|
-tp | Field Plus tags — uses modern field-based tags (Word field / Excel macro). Recommended for all current templates | ✅ Yes |
-tf | Field tags — uses legacy field-based tags (Word field / Excel macro) | |
-tt | Text tags — uses plain text tags | |
-tc | Content Control tags — uses Word Content Controls / Excel macros |
Other options
| Flag | Description | Default |
|---|---|---|
-ru | Disables removal of unused styles, fonts, and other resources from the template | Removal is ON by default; use -ru to turn it OFF |
-sq | Disables smart quote removal — keeps quotes around ${vars} | Smart quote removal is ON by default; use -sq to turn it OFF. Must appear before any -sql or -xml datasource flags |
-fe | Attempts to fix evaluable expressions in the template | Off by default |
Legacy version flags
Use these flags when cleaning a template that was originally created with an older version of Fluent. Setting the wrong flag will cause select types to be converted incorrectly.
| Flag | Description |
|---|---|
-v9 | Template was created with Fluent version 9 or earlier |
-v14 | Template was created with Fluent version 14 or earlier |
Datasources
Declare the datasource types used in the template. Multiple datasource flags can be provided. Each declaration can optionally include a datasource name using the :<name> syntax.
| Flag | Description |
|---|---|
-json | JSON datasource (unnamed) |
-json:<name> | JSON datasource with a specific name |
-odata | OData datasource (unnamed) |
-odata:<name> | OData datasource with a specific name |
-sql | SQL datasource (unnamed) |
-sql:<name> | SQL datasource with a specific name |
-xml | XML datasource (unnamed) |
-xml:<name> | XML datasource with a specific name |
Datasource flags must appear after -sq (smart quote flag) if you want smart quote removal to apply to those datasources. The -sq flag only affects datasource declarations that follow it.
Examples
Clean a single Word template using all defaults:
CleanTemplates.exe C:\templates\invoice.docx C:\templates\cleaned
Clean all Excel templates in a folder:
CleanTemplates.exe C:\templates\*.xlsx C:\templates\cleaned
Clean a template with a named SQL and XML datasource:
CleanTemplates.exe -sql:NorthWind -xml:Products C:\templates\report.docx C:\output
Clean a legacy version 9 template, switching to Field Plus tags:
CleanTemplates.exe -v9 -tp C:\old-templates\report.docx C:\output
Clean a template with substitution parameter mode and smart quotes disabled:
CleanTemplates.exe -ps -sq C:\templates\report.docx C:\output
Clean an RTF template (requires Microsoft Office):
CleanTemplates.exe C:\templates\letter.rtf C:\output