StringTemplate

StringTemplate["string"]
yields a TemplateObject that represents a string template to be applied to arguments.

StringTemplate[src]
uses a , , or CloudObject as the source for the string template.

StringTemplate[form,args]
yields a TemplateObject with arguments, suitable for cloud deployment or other evaluation.

Details and OptionsDetails and Options

ExamplesExamplesopen allclose all

Basic Examples  (4)Basic Examples  (4)

Apply a string template with slots named and :

In[1]:=
Click for copyable input
Out[1]=

An equivalent form using TemplateApply:

In[2]:=
Click for copyable input
Out[2]=

The StringTemplate is not needed inside TemplateApply:

In[3]:=
Click for copyable input
Out[3]=

Apply a string template to positional arguments:

In[1]:=
Click for copyable input
Out[1]=

An equivalent form:

In[2]:=
Click for copyable input

The expression inside is evaluated when the string template is applied:

In[1]:=
Click for copyable input
Out[1]=

Include a template slot as well as an expression in the template string:

In[2]:=
Click for copyable input
Out[2]=

Values from the association can be used in the template expression:

In[3]:=
Click for copyable input
Out[3]=

Rule delayed can be used to delay computations:

In[4]:=
Click for copyable input
Out[4]=
In[5]:=
Click for copyable input
Out[5]=

Expressions are spliced into the string using TextString:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2014
(10.0)
Translate this page: