sprintf
A general purpose formatter based on the sprintf command found in a number of programming languages. The value of the attribute should be the format string. The tag value will be passed in as the argument to sprintf.
Examples ¶
Format the entry count with parentheses and pad with zeros to 6 digits:
<$mt:EntryCommentCount sprintf="(%.6d)"$>
Result for an entry with 23 comments:
(000023)
Format the month number with a proceeding 0 if number is a single digit:
<$mt:Var name="month_number" value="2"$>
<$mt:Var name="month_number" sprintf="%02d"$>
Output for month “2” (February):
02
Convert the value of TagName into a floating point number with a precision of 2:
<$mt:TagName sprintf="%.2f"$>
Related ¶
- Guide to the printf format
- More examples of
sprintf:

Leave a note
Have a question? Please use the MT Forums. Notes submitted on documentation should pertain to tips & hints regarding documentation. Your note may be removed once its contents have been integrated into the body of the page.