Webtags/Parameters (preserving history): Difference between revisions

From Cumulus Wiki
Jump to navigationJump to search
m
→‎Use of spaces: Now the section has the links to other sections and works from simple to complex
m (→‎Use of spaces: Now the section has the links to other sections and works from simple to complex)
Line 208: Line 208:
There are multiple symbols for specifying dates and times, and you might want spaces to appear between symbols 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.


You need to add quotation marks to the output format specifier if spaces are present.  
You need to add quotation marks to the output format specifier if spaces are present.


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">'''.   
The first complication is that the parser that interprets time/date characters has two ways of interpreting a space character, depending on what immediately follows.  In the tables, below, I have used a "%" in various places. In any of those places, a space is not a gap between characters, but an alternative to "%".  I discuss this later in [[#Migrating from legacy Cumulus 1 to MX]] section.


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>'">'''.
For a space character to be interpreted as a gap between symbols, the symbol that follows the space must include at least two characters. The syntax <code><#tag_name format="x y z"></code> works if the y and z in it are representing multi-character symbols. To explain this, an example is '''<#TpressTH format="h:mm tt">''' as both ''h:mm'' and ''tt'' are multi-character symbols, we have inserted a space after the minutes.
 
That approach would not work if we wanted to use single character specifiers, a simple example is '''<#MonthPressHD format=" d' 'M">''', here the month number is a single character "M", so to insert the space we have to treat it as a literal by enclosing it in single quotes. Literals are discussed fully in the [[#Including literals in format parameters]] sub-section later. If we want to include other characters not to be interpreted by the date time parameter parser, and spaces, 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.
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.
5,838

edits

Navigation menu