Skip to main content

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 .rtf or 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.

caution

The output file cannot be the same as the input file. CleanTemplates will not overwrite the original template.

info

Always make a back up copy of your templates before using this tool.

Supported template formats

ExtensionFormat
.docx, .dotxWord Open XML
.docm, .dotmWord Open XML (macro-enabled)
.xlsxExcel Open XML
.xlsmExcel Open XML (macro-enabled)
.pptxPowerPoint Open XML
.rtfRich Text Format (converted to .docx via Word — requires Office)
.xmlWord 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.

FlagDescriptionDefault
-ppParameter Plus — parameters are written as ${name} with surrounding quotes preserved✅ Yes
-poParameter Only — parameters are written as ${name} with no additional formatting
-psSubstitution — 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.

FlagDescriptionDefault
-tpField Plus tags — uses modern field-based tags (Word field / Excel macro). Recommended for all current templates✅ Yes
-tfField tags — uses legacy field-based tags (Word field / Excel macro)
-ttText tags — uses plain text tags
-tcContent Control tags — uses Word Content Controls / Excel macros

Other options

FlagDescriptionDefault
-ruDisables removal of unused styles, fonts, and other resources from the templateRemoval is ON by default; use -ru to turn it OFF
-sqDisables 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
-feAttempts to fix evaluable expressions in the templateOff 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.

FlagDescription
-v9Template was created with Fluent version 9 or earlier
-v14Template 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.

FlagDescription
-jsonJSON datasource (unnamed)
-json:<name>JSON datasource with a specific name
-odataOData datasource (unnamed)
-odata:<name>OData datasource with a specific name
-sqlSQL datasource (unnamed)
-sql:<name>SQL datasource with a specific name
-xmlXML datasource (unnamed)
-xml:<name>XML datasource with a specific name
note

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