version=pmwiki-2.2.0-beta52 ordered=1 urlencoded=1
agent=Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.8.1.2) Gecko/20061023 SUSE/2.0.0.2-1.1 Firefox/2.0.0.2
author=Pm
charset=ISO-8859-1
csum=
ctime=1176718061
host=76.183.97.54
name=PmWiki.MarkupExpressions
rev=11
targets=PmWiki.DocumentationIndex
text=(:Summary:Markup expressions:)%0a%25audience%25 authors (advanced)%0a%0aThe [@{(...)}@] "expression markup" allows for a variety of string and formatting operations to be performed from within markup.  Operations defined by this recipe include ''substr'', ''ftime'', ''strlen'', ''rand'', ''toupper'', ''tolower'', ''ucfirst'', ''ucwords'', ''pagename'', and ''asspaced''.%0a%0a-> %25note%25 Markup Expressions were introduced in PmWiki 2.2.0-beta43.  %0a%0a!! ''substr''%0a%0aThe "substr" expression extracts portions of a string.  The first argument is the string to be processed, the second argument is the initial position of the substring, and the third argument is the number of characters to extract.  Note that the initial position argument is zero-based (i.e., the first character is referenced via a "0").%0a%0a(:markup class="horiz":)%0a {(substr "PmWiki" 2 3)}%0a {(substr "PmWiki" 2)}%0a {(substr "PmWiki" 0 1)}%0a(:markupend:)%0a%0a!! ''ftime''%0a%0a"Ftime" expressions are used for date and time formatting.  The generic form is%0a%0a->[@{(ftime "fmt" "when")}@]%0a->[@{(ftime fmt="fmt" when="when")}@]%0a%0awhere ''fmt'' is a formatting string and ''when'' is the time to be formatted.  The arguments can be in either order and may use the optional "fmt=" and "when=" labels.%0a%0aExamples:%0a(:markup class="horiz":)%0a {(ftime fmt="%25F %25H:%25M")}%0a {(ftime %25Y)}%0a {(ftime fmt=%25F)}%0a {(ftime yesterday)}%0a {(ftime when=tomorrow)}%0a {(ftime %25F yesterday)}%0a {(ftime week %25F)}%0a {(ftime fmt=%25F month)}%0a(:markupend:)%0a%0aThe ''fmt'' parameter is whatever is given by "fmt=", the first parameter containing a '%25', or else the site's default.  The formatting codes are described at %25newwin%25 http://www.php.net/strftime.  Some common formatting strings:%0a%0a    [= %25F            =]    # ISO-8601 dates      "{(ftime %25F)}"%0a    [= %25H:%25M:%25S      =]    # time as hh:mm:ss    "{(ftime %25H:%25M:%25S)}"%0a    [= %25m/%25d/%25Y      =]    # date as mm/dd/yyyy  "{(ftime %25m/%25d/%25Y)}"%0a    [= "%25A, %25B %25d, %25Y" =]  # in words            "{(ftime "%25A, %25B %25d, %25Y")}"%0a%0aThe ''when'' parameter understands many different date formats.  The when parameter is whatever is given by "when=", or whatever parameter remains after determining the format parameter.  Some examples:%0a%0a    2007-04-11            # ISO-8601 dates%0a    20070411              # dates without hyphens, slashes, or dots%0a    2007-03               # months%0a    @1176304315           # Unix timestamps (seconds since 1-Jan-1970 00:00 UTC)%0a    now                   # the current time%0a    today                 # today @ 00:00:00%0a    yesterday             # yesterday @ 00:00:00%0a    "next Monday"         # relative dates%0a    "last Thursday"       # relative dates%0a    "-3 days"             # three days ago%0a    "+2 weeks"            # two weeks from now%0a    "2007-04-11 -4 days"  # four days before April 11%0a%0aThe ''when'' parameter uses PHP's %25newwin%25[[(http://www.php.net/)strtotime]] function to convert date strings according to the GNU [[http://gnu.org/software/tar/manual/html_node/tar_109.html|date input formats]]; as of this writing it only understands English phrases in date specifications.%0a%0aThe variable $FTimeFmt can be used to override the default date format used by the "ftime" function.  The default $FTimeFmt is $TimeFmt.%0a%0a!! ''strlen''%0a%0aThe "strlen" expression returns the length of a string.  The first argument is the string to be measured.%0a%0a(:markup class="horiz":)%0a {(strlen "{$:Summary}")}%0a(:markupend:)%0a%0a!! ''rand''%0a%0aThe "rand" expression returns a random integer.  The first argument is the minimum number to be returned and the second argument is the maximum number to be returned.  If called without the optional min, max arguments rand() returns a pseudo-random integer between 0 and RAND_MAX. If you want a random number between 5 and 15 (inclusive), for example, use rand (5, 15).%0a%0a(:markup class="horiz":)%0a {(rand)}%0a(:markupend:)%0a%0a!! ''toupper'' / ''tolower''%0a%0aThe "toupper" and "tolower" expressions convert a string into uppercase or lowercase.  The first argument is the string to be processed.%0a%0a(:markup class="horiz":)%0a {(toupper "{$:Summary}")}%0a {(tolower "{$:Summary}")}%0a(:markupend:)%0a%0a!! ''ucfirst''%0a%0aThe "ucfirst" expression converts the first character of a string to uppercase.  The first argument is the string to be processed.%0a%0a(:markup class="horiz":)%0a {(ucfirst "{$:Summary}")}%0a(:markupend:)%0a%0a!! ''ucwords''%0a%0aThe "ucwords" expression converts the first character of each word in a string to uppercase.  The first argument is the string to be processed.%0a%0a(:markup class="horiz":)%0a {(ucwords "{$:Summary}")}%0a(:markupend:)%0a%0a!! ''pagename''%0a%0aThe "pagename" expression builds a pagename from a string.  The first argument is the string to be processed.%0a%0a!! ''asspaced''%0a%0aThe "asspaced" expression formats wikiwords.  The first argument is the string to be processed.%0a%0a!! Nesting expressions%0a%0aMarkup expressions can be nested:%0a%0a(:markup class="horiz":)%0a {(tolower (substr "Hello World" 2))}%0a(:markupend:)%0a    %0a!! Notes%0a%0a* Some of the string-processing markups may not work properly on UTF-8 characters or escaped sequences.%0a%0a%25trail%25 %3c%3c|[[Documentation Index]]|>>%0a%0a
time=1180212993
