This version is out of date, covering development as far as v4.2.5. It is maintained here only for inbound reference links from elsewhere.
Jump to the current version of aTbRef.
|A Tinderbox Reference File : Actions & Rules : format() operator|
The new v4.0.0 operator format() converts various Tinderbox objects to strings.
The argument what is usually an attribute reference or expression.
The meaning of format_string depends on the type of object represented by what. Tinderbox data types Date, Set and Number are handled using different sets of arguments as described below.
If what is a date, the format string is the same as the format used by Tinderbox's date export codes.
gets the note's creation date and formats it as a "long local date" such as "Sunday, March 23, 2007 1:26pm".
If what is a Set, the format string is the delimiter used to separate set elements:
converts key attributes to a comma-separated list. Optionally, you may supply five arguments to format the set as an HTML list:
will return HTML code for a bulleted list with each set member marked up as a list item. Note that the tags must be in double quotes.
To make this easier to use in a code export context, pass the output of format into another attribute and call the latter in the template with a ^get()^ code.
If what is a number, then the arguments are numeric and interpreted as follows:
The precision argument controls the number of decimal places returned. The optional width argument allows the returned value to be a string left padded with spaces - e.g. to return a string with the same number of characters as submitted.
For example, if $myNum is 3.1415927, then
format($myNum,2,7) is " 3.14"
format($myNum,2) is 3.14
format*$myNum,0) is 3
In quoted (") string arguments here - as elsewhere in v4.0.0+, \" is converted into a quotation mark (a.k.a. a double quote), \n to a carriage return and \t to a tab.
v4.2.0 fixed some issues with formatting dates prior to 1904.
|Up: Actions & Rules|
|Previous: every() operator||Next: sum() operator|
Licensed under Creative Commons Attribution-Noncommercial-Share Alike 3.0 License
[See aTbRef CC licence Attribution/Waiver info info]