TemplateApply
✖
TemplateApply
Details and Options

- The template in TemplateApply can be an explicit TemplateObject, as generated from StringTemplate, FileTemplate, XMLTemplate, or NotebookTemplate.
- The following special forms can also be used directly as templates:
-
"string" string template File["filename.xx"] general file template File["filename.html"] etc. XML-like file template File["filename.nb"] etc. notebook-like file template URL[…] a URL pointing to a file template NotebookObject[…] notebook template CloudObject[…] template type based on the contents of the cloud object - In TemplateApply[template,args], args can have the following forms:
-
{arg1,arg2,…} positional arguments <"name1"->val1,"name2"->val2,… > named arguments - In string and general file templates, positional arguments corresponding to TemplateSlot[i] can be referred to using `` and `i`. Named arguments corresponding to TemplateSlot["namei"] can be referred to using `namei`. TemplateExpression elements can be given as <*…*>.
Examples
open allclose allBasic Examples (3)Summary of the most common use cases

https://wolfram.com/xid/0puwgsqjk0-i6p7hl


https://wolfram.com/xid/0puwgsqjk0-4gn4zv


https://wolfram.com/xid/0puwgsqjk0-sbf42x

TemplateApply works with any expression:

https://wolfram.com/xid/0puwgsqjk0-hmr9ms

TemplateApply can be used directly on strings; in that case, the string is taken to be a StringTemplate:

https://wolfram.com/xid/0puwgsqjk0-jwh3aj

TemplateApply can be used to build held expressions:

https://wolfram.com/xid/0puwgsqjk0-066igr


https://wolfram.com/xid/0puwgsqjk0-ics4uo

Scope (5)Survey of the scope of standard use cases
TemplateApply can be used to parse and apply a StringTemplate in one step:

https://wolfram.com/xid/0puwgsqjk0-8qyixc

File is fully supported:

https://wolfram.com/xid/0puwgsqjk0-f48c8p

Templates can be hosted in the Wolfram Cloud:

https://wolfram.com/xid/0puwgsqjk0-zn99tp

CloudObject can be directly used by TemplateApply:

https://wolfram.com/xid/0puwgsqjk0-euzfet

The second argument of any TemplateObject can be used to bound data to the template:

https://wolfram.com/xid/0puwgsqjk0-u7p483


https://wolfram.com/xid/0puwgsqjk0-8tx9dm

URL can be used to fetch templates:

https://wolfram.com/xid/0puwgsqjk0-ehr44g


https://wolfram.com/xid/0puwgsqjk0-uwsajo


https://wolfram.com/xid/0puwgsqjk0-se9tn7

URL can be directly used by TemplateApply:

https://wolfram.com/xid/0puwgsqjk0-6etf82

Generalizations & Extensions (2)Generalized and extended use cases
CombinerFunction (1)
Specify a different way to combine parts of templates:
Using CombinerFunction:

https://wolfram.com/xid/0puwgsqjk0-4bhzn7

Applications (1)Sample problems that can be solved with this function
TemplateApply can be used to build complex expressions:

https://wolfram.com/xid/0puwgsqjk0-fhg6px


https://wolfram.com/xid/0puwgsqjk0-kks95h

Properties & Relations (1)Properties of the function, and connections to other functions
If you deploy a template with data, each time you visit it TemplateApply will render the content again:

https://wolfram.com/xid/0puwgsqjk0-kwsq8a

Neat Examples (1)Surprising or curious use cases
You can deploy any TemplateObject to the cloud. When you visit the URL, TemplateApply will render the template on each visit:

https://wolfram.com/xid/0puwgsqjk0-bat1nv

Wolfram Research (2014), TemplateApply, Wolfram Language function, https://reference.wolfram.com/language/ref/TemplateApply.html (updated 2016).
Text
Wolfram Research (2014), TemplateApply, Wolfram Language function, https://reference.wolfram.com/language/ref/TemplateApply.html (updated 2016).
Wolfram Research (2014), TemplateApply, Wolfram Language function, https://reference.wolfram.com/language/ref/TemplateApply.html (updated 2016).
CMS
Wolfram Language. 2014. "TemplateApply." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/TemplateApply.html.
Wolfram Language. 2014. "TemplateApply." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/TemplateApply.html.
APA
Wolfram Language. (2014). TemplateApply. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TemplateApply.html
Wolfram Language. (2014). TemplateApply. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TemplateApply.html
BibTeX
@misc{reference.wolfram_2025_templateapply, author="Wolfram Research", title="{TemplateApply}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/TemplateApply.html}", note=[Accessed: 25-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_templateapply, organization={Wolfram Research}, title={TemplateApply}, year={2016}, url={https://reference.wolfram.com/language/ref/TemplateApply.html}, note=[Accessed: 25-March-2025
]}