({{, (RefLink[FileTemplate, paclet:ref/FileTemplate])["file"] 
yields a (RefLink[TemplateObject, paclet:ref/TemplateObject]) expression that represents a file template to be applied using functions like (RefLink[TemplateApply, paclet:ref/TemplateApply]).}, {, (RefLink[FileTemplate, paclet:ref/FileTemplate])[src]
uses (RefLink[File, paclet:ref/File])[…], (RefLink[URL, paclet:ref/URL])[…], or (RefLink[CloudObject, paclet:ref/CloudObject])[…] as the specification for the file location.}, {, (RefLink[FileTemplate, paclet:ref/FileTemplate])[form,args]
yields a (RefLink[TemplateObject, paclet:ref/TemplateObject]) with arguments, suitable for cloud deployment or other evaluation.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[FileTemplate, paclet:ref/FileTemplate]) will infer from the extension whether to interpret the contents as a (RefLink[StringTemplate, paclet:ref/StringTemplate]), (RefLink[XMLTemplate, paclet:ref/XMLTemplate]), or (RefLink[NotebookTemplate, paclet:ref/NotebookTemplate]).

(RefLink[FileTemplate, paclet:ref/FileTemplate])[(RefLink[CloudObject, paclet:ref/CloudObject])[…]] will infer the template type based on the contents of the cloud object.

(RefLink[FileTemplate, paclet:ref/FileTemplate])[(RefLink[File, paclet:ref/File])["path"]] and (RefLink[FileTemplate, paclet:ref/FileTemplate])["path"] are effectively equivalent.

The following special forms can be used in the file for (RefLink[FileTemplate, paclet:ref/FileTemplate]):

(RefLink[FileTemplate, paclet:ref/FileTemplate]) has the following options:

OpenersPrimaryExamplesSection(Spacer1)Examples  (7)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Loading a template file from disk:

t = FileTemplate["Examples/String/object.txt"]

Applying to a (RefLink[FileTemplate, paclet:ref/FileTemplate]):

TemplateApply[t, <| "object" -> "planet", "attribute" -> "big" |>]

Saving a template to disk:

FileTemplateApply[t, <| "object" -> "planet", "attribute" -> "big" |>]

The type of template to use is by default determined by the extension:

TemplateApply[
FileTemplate["Examples/XML/which.html"],
<|"data" -> {"Jupiter", "Earth", "Mars"}|>
]

Evaluate (RefLink[$TemplatePath, paclet:ref/$TemplatePath]) to see where (RefLink[FileTemplate, paclet:ref/FileTemplate]) is searching for templates:

$TemplatePath

OpenersExampleSection1(Spacer1)Scope  (3)

(RefLink[File, paclet:ref/File]) is fully supported:

FileTemplate[File["Examples/XML/sequence.html"]]

Templates can be hosted in the Wolfram Cloud:

template = CloudDeploy[StringTemplate["hello i'm `Name`"]]

FileTemplate[template]

(RefLink[URL, paclet:ref/URL]) can be used to fetch templates:

template = URL @@ CloudExport["hi i'm `Name`", "String"]

URLRead[template, "Body"]

FileTemplate[template]

(RefLink[URL, paclet:ref/URL]) can be directly used by (RefLink[TemplateApply, paclet:ref/TemplateApply]):

TemplateApply[template, <|"Name" -> "john"|>]

OpenersExampleSection2(Spacer1)Options  (2)

OpenersExampleSubsection0(Spacer1)InsertionFunction  (1)

Specify a function to convert arguments before they are inserted:

TemplateApply[
FileTemplate[
"Examples/XML/sequence.html",
InsertionFunction -> Composition[ToUpperCase, TextString]
],
<|"data" -> {"Jupiter", "Earth", "Mars"}|>
]

TemplateApply[
FileTemplate[
"Examples/String/url.txt",
InsertionFunction -> URLEncode
],
<|"input" -> "Jupiter distance"|>
]

You can use a string to specify an export format:

t = FileTemplate[
"Examples/String/object.txt",
InsertionFunction-> "JSON"
];

t[<|"object" -> {"list", "of", "data"}, "attribute" -> <|"json" -> "object"|>|>]

OpenersExampleSubsection1(Spacer1)CombinerFunction  (1)

Specify a different way to combine parts of templates:

TemplateApply[
FileTemplate[
"Examples/XML/sequence.html",
CombinerFunction -> Composition[ToUpperCase, StringJoin]
],
<|"data" -> {"Jupiter", "Earth", "Mars"}|>
]

OpenersExampleSection3(Spacer1)Properties & Relations  (1)

If you deploy a template with data, each time you visit it (RefLink[TemplateApply, paclet:ref/TemplateApply]) will render the content again:

CloudDeploy[
FileTemplate[
File["Examples/XML/sequence.html"], 
<|"data" :> {Now, RandomReal[], RandomReal[]}|>
]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[XMLTemplate, paclet:ref/XMLTemplate])  ▪  (RefLink[StringTemplate, paclet:ref/StringTemplate])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[File Operations, paclet:guide/FileOperations])}, {▪(RefLinkPlain[Working with Templates, paclet:guide/WorkingWithTemplates])}, {▪(RefLinkPlain[External Interpreted Language Interfaces, paclet:guide/ExternalInterpretedLanguageInterfaces])}, {▪(RefLinkPlain[External Language Interfaces, paclet:guide/ExternalLanguageInterfaces])}, {▪(RefLinkPlain[Text Generation, paclet:guide/TextConstruction])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/42-string-patterns-and-templates.html])(WebLink[: String Patterns and Templates , https://www.wolfram.com/language/elementary-introduction/42-string-patterns-and-templates.html])}})}})