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 allclose all

Basic Examples  (1)

Using TemplateIf:

Run a test over a TemplateSlot:

Options  (1)

InsertionFunction  (1)

Using an InsertionFunction:

InsertionFunction can be any function:

Wolfram Research (2014), TemplateIf, Wolfram Language function, https://reference.wolfram.com/language/ref/TemplateIf.html.

Text

Wolfram Research (2014), TemplateIf, Wolfram Language function, https://reference.wolfram.com/language/ref/TemplateIf.html.

CMS

Wolfram Language. 2014. "TemplateIf." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TemplateIf.html.

APA

Wolfram Language. (2014). TemplateIf. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TemplateIf.html

BibTeX

@misc{reference.wolfram_2024_templateif, author="Wolfram Research", title="{TemplateIf}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/TemplateIf.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_templateif, organization={Wolfram Research}, title={TemplateIf}, year={2014}, url={https://reference.wolfram.com/language/ref/TemplateIf.html}, note=[Accessed: 21-November-2024 ]}