Webtags/Parameters (preserving history): Difference between revisions

m
→‎Use of spaces: Now rewritten whole section, as decided to add examples
m (→‎Use of spaces: Rewrite of last paragraph)
m (→‎Use of spaces: Now rewritten whole section, as decided to add examples)
Line 206: Line 206:
===Use of spaces===
===Use of spaces===


There are multiple parameters for specifying dates and times, and you might want spaces to appear in that output format.
There are multiple symbols for specifying dates and times, and you might want spaces to appear between symbols in that output format.


If we need to include spaces, then we have to enclose the whole specifier in double quotation marks e.g. <code><#tag_name format="x y z"></code>
You need to add quotation marks to the output format specifier if spaces are present.  


Any literals (i.e. characters we do not want to be interpreted by the date time parameter parser) are generally enclosed in single quotation marks, within the double quotation marks delimiting the specifier. You will find literals discussed fully at [[#Including literals in format parameters]] later.
A simple output format modifier, which only quotes valid time/date symbols but adds some spaces would have double quotes delimiting the specifier, the syntax is <code><#tag_name format="x y z"></code> and an example is '''<#TpressTH format="h:mm tt">'''.


For now just remember, the use of literals can cause you a problem if you want to use a date/time specification in a script because the script wants literal delimiters outside any web tags, so that delimiters remain when the web tag itself has been processed into a string by Cumulus.  The complicated sounding (but actually simple solution) is to avoid placing literals within any output format specifier, instead put single quotes round the whole content. What you thought of putting as literals within any web tag is instead typed outside with separate web tags for the part of the specification before and after each literal.
It becomes more complicated if we need to include other characters not to be interpreted by the date time parameter parser. Such literals are discussed fully in the [[#Including literals in format parameters]] sub-section later. Here it is just essential to say that if spaces and other literal text are wanted as well as valid date/time symbols, then both double and single quotes must be used, and the spaces must be within the single quotes.  An example, that shows all the options that MX allows, with literals is '''<#TpressH format="\a't 'h:mm'&nbsp;' tt' <small>on 'd/M/yyyy' </small>'">'''.
 
Finally, the use of literals can cause you ''a problem if you want to use a date/time specification in a script'' because the script wants literal delimiters outside any web tags, so that delimiters remain when the web tag itself has been processed into a string by Cumulus.  This means the type of quotes (single or double) used outside the web tag, cannot be used within the web tag. The complicated sounding (but actually simple solution) is to avoid placing literals, and/or spaces, within any output format specifier, instead put single quotes round the whole content. What you thought of putting as literals within any web tag is instead typed outside with separate web tags for the part of the specification before and after each literal.


===Which tag names take date/time output formatting modifiers===
===Which tag names take date/time output formatting modifiers===
5,838

edits