tmplat

Operations are performed using sections, accepting its rendered contents as an argument.

Definitions
Name Argument Description
capitalise Text Transform the text provided into title case
Text Get the value for the cookie with the name provided
dateTime Text Format the current date & time using the pattern provided
(see PHPs date for more details)
decode Text Decode the previously encoded text provided
encode Text Encode the text provided so that it can be safely used in a query string
escape New Text Escape the text provided so that it can be safely inserted into HTML
fparam Text Get the value of the parameter provided from within the hash fragment
fsegment Number Get the segment at the index provided from within the hash fragment
lastModified ¹ Text Format the last modified date & time using the pattern provided
(see PHPs date for more details)
length Text Get the character length of the text provided
lowerCase Text Transform the text provided into lower case
meta ¹New Text Get the content of the page's meta information with the text provided
param Text Get the value of the parameter provided
segment Number Get the segment at the index provided
select ¹ Text ² Get the text of first matching element
selectAll ¹ Text ² Concatenate the text of all matching elements
selectAllHTML ¹ Text ² Concatenate the HTML contents of all matching elements
selectAllMarkdown ¹ Text ² Concatenate the contents of all matching elements as Markdown
selectHTML ¹ Text ² Get the HTML contents of the first matching element
selectMarkdown ¹ Text ² Get the contents of the first matching element as Markdown
shorten Text Shorten the URL provided using the active URL shortener
tidy Text Reduce all of the joined spaces and tabs into single spaces within the text provided before removing all leading and trailing whitespace
trim Text Remove all leading and trailing whitespace from the text provided
trimLeft Text Remove all leading whitespace from the text provided
trimRight Text Remove all trailing whitespace from the text provided
unescape New Text The opposite of escape; Replace escaped characters in text provided with their unescaped counterparts
upperCase Text Transform the text provided into upper case
wordCount New Text Get the number of words in the text provided
xpath ¹New Text ³ Get the first result for the XPath expression as text
xpathAll ¹New Text ³ Concatenate all results for the XPath expression
xpathAllHTML ¹New Text ³ Concatenate the HTML contents of all results for the XPath expression
xpathAllMarkdown ¹New Text ³ Concatenate the contents of all results for the XPath expression as Markdown
xpathHTML ¹New Text ³ Get the HTML contents of the first result for the XPath expression
xpathMarkdown ¹New Text ³ Get the contents of the first result for the XPath expression as Markdown

This page's information will be used in the following examples.

To output the current date & time in ISO 8601 format you would use;

Today is {#dateTime}Y-m-d\TH:i:sP{/dateTime}.

Also, the c parameter would also have the same outcome in this case. If you wanted to safely pass the whole URL as a parameter in a query string;

http://example.com/something.do?url={#encode}{url}{/encode}

This escapes all of the necessary characters within URL and outputs the following;

http://example.com/something.do?url=https%3A%2F%2Ftmplat.com%2Fguide%2Foperations

To access the last segment of the URL's path;

I am currently viewing "{#segment}-1{/segment}".

Would render the following output;

I am currently viewing "operations".

Let's pretend again that the query string for this page is foo=bar&fu=baz. Accessing the value of the foo parameter is as simple as the following;

The value of foo is "{#param}foo{/param}".

This would cause the following output to be rendered;

The value of foo is "bar".

Notes

The following notes only apply to segment and fsegment operations;

  • The count is not zero-indexed like an array (e.g. {#segment}1{/segment} returns the first segment)
  • The argument can be negative values, in which case it will count back from the end of the path rather than forwards from the start