<:val expr [fmt="plain"]:>
Causes the Python expression expr to be evaluated, and the resulting Python object is converted to a string and displayed at that place in your document. (All Python objects can be turned into strings.)
For example, if you would like to display the result of 5 + 2:
<:val `5 + 2`:>
The <:val:> tag is just like calling the str() function in Python on the resulting object, with one exception: if the object is the None object, <:val:> prints an empty string "" instead of the string "None". The following two tags show the value of the variable named myVar and show nothing, respectively:
<:val `myVar`:> <:val `None`:>
<:val:> only accepts Python expressions as its attribute,
not full Python statements. That means that you cannot assign
objects to variable names with this tag. Use the
<:set:> (see section 2.2, page
<:val `myFunction()`:>
The string printed by <:val:> is just a plain string by default; no special formatting takes place. Sometimes you want the string to be formatted in a special way: you want HTML special characters escaped, or you want all characters escaped so that the string can be made part of a URL. The fmt argument lets you specify one of many common formatting or escaping operations on the string:
Examples of fmt, with the output shown after each example:
<:set myVar "Click here >>>>":> <:val `myVar`:> Click here >>>> <:val `myVar` fmt="html":> Click here >>>> <:val `myVar` fmt="url":> Click%20here%20%3E%3E%3E%3E <:val `myVar` fmt="fullurl":> %43%6C%69%63%6B%20%68%65%72%65%20%3E%3E%3E%3E
The <:val:>
tag is equivalent to the following code executed
in a Python component:
import DT.DTCommon print DT.DTCommon.ValFmtRgy[fmt](expr)