TemplateIf

TemplateIf[condition,tclause]

represents an element of a template object that inserts tclause if the condition evaluates to True.

TemplateIf[condition,tclause,fclause]

inserts fclause if the condition does not evaluate to True.

Details and Options

  • condition can be either a TemplateSlot or TemplateExpression.
  • The tclause is used when condition===True.
  • If an fclause is not provided, the value Sequence[] is used instead.
  • In an XML template, TemplateIf can be indicated using <wolfram:condition>...</wolfram:condition>. Multiple conditions can be nested using <wolfram:switch><wolfram:condition>...</wolfram:condition>...<wolfram:else>...</wolfram:else></wolfram:switch>.
  • TemplateIf has the option InsertionFunction, with default setting Inherited, which specifies how the content of each template slot should be formatted before inserting it.

Examples

open all close all

Basic Examples  (1)

Using TemplateIf:

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

Run a test over a TemplateSlot:

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

Options  (1)

Introduced in 2014
(10.0)