- Theme Engine
- EVML Reference
- Statements and Declarations
- Built-in Functions
- Built-in Objects
- EV Tags
- CSS Pre-processor
- Ajax API
Extends Literal. Strings contain characters or numbers and may be any text within single or double quotes. They do differ so it's worth reading further.
Single quoted strings
Strings enveloped within single quotes are taken as literal strings with only two escaped characters:
- To specify a literal single quote, escape it with a backslash (\).
- To specify a literal backslash, double it (\\).
Any other escape sequences you might be used to, such as \r or \n, will be output literally as part of the string and don't have any special meaning.
// a simple string within single quotes var myString1 = 'It\'s my Birthday today'; // It's my Birthday today // strings may have embedded new lines var myString2 = 'You can also have embedded newlines in strings this way as it is okay to do'; var myString3 = 'A \n is just part of a string in single quotes';
Double quoted strings
Strings enveloped within double quotes are not so literal and accept a range of escape sequences.
var myString2 = "text within \n double quotes"; // the \n represents a new line
EV Script accepts the following escape strings within double quoted strings:
Any other character sequence will result in a literal string interpretation.
The number of characters in the String.
Returns a new unencoded string leaving the original base64 encoded string unmutated.
Returns a new base64 encoded string leaving the original string unmutated.
Returns a character at the supplied index. If an index is not supplied the first character of the string will be returned. Note that in EVML indexes start from 0. So the first character of a string has an index of 0.
Determines whether one string may be found within another string. This method accepts a simple string, but also allows a regular expression. Returns true if the pattern exists or false if not.
Determines whether a string ends with the character(s) of another string, returning
Escape the string into a safer representation of itself by converting special HTML characters into visual representation of the String rather than as code.
This method is important in escaping user input or data within HTML attributes.
Returns the first character of the String.
Determines whether the String contains HTML, returning
Returns the last character of the String.
Alias of String.nl2br().
Returns a new String converting embedded or escaped newlines (\n within double quoted strings) to an HTML break (<br>) tag.
Remove HTML tags from the String returning a new String with the result. You may permit some tags using the exceptions argument to this method. These are supplied as a String of tags e.g. "<p><br>". tag.
|replace(String:pattern, String:replacement [, Number:limit])||
Search the current string for a pattern and replace them with a replacement and return a new String with the result.
|split(String:separator [, Number:limit])||
Determines whether a string starts with the character(s) of another string, returning
|substring(Number:start [, Number:length])||
Returns a segment of a string, at least one character in length, determined by the start and length parameters.
Convert the current String to a Boolean and return the result. Strings with no length are result in a false value, whilst strings with length are returned as true.
Represent the current string as a hexideciaml colour reference in a new String leaving the original unmutated.
Convert a String containing valid HTML/XML format to a Dom Object. The toDom() method is a great little tool and can, in some cases, come in handy, because it gives us access to JQuery style Dom methods, but at server-side. For example:
Convert the string into an identifier. This is generally useful in creating an ID or a URL slug from any String. Whitespace by default is replaced by a dash '-' unless requested otherwise as an argument. Characters that are not alphabetical or numerical are removed.
Alias of String.toLowerCase() - it's just a shorter version.
Returns a new String with all alphabetical letters in lower case.
Convert the string into a Number and returns the result. The original String mustcontain a numeric value.
Alias of String.toUpperCase() - it's shorter because we're lazy.
Returns a new String with all alphabetical letters in upper case.
Returns a new Url object based on the original String. This does of course mean that the original string must be either a relative or absolute Url.
Returns a new String with any whitespace removed from the beginning or end of the original. The following whitespace characters will be removed:
|truncate(Number:length [, String:suffix])||
Return a new String shortened to the number of characters requested by the length argument. If the originating string is longer than length a String returned includes a suffix. The default value for suffix is … (…).
Alias of String.upperCaseFirst().
Alias of String.upperCaseWords().
Returns a new String with the first character capitalized, if it's alphabetic.
Returns a new String with the first character of each word capitalized, if that character is alphabetic.
Returns a new unencoded String leaving the original URL encoded string unmutated.
Returns a new URL encoded String leaving the original string unmutated.
Wrap the current string with any valid HTML/XML tag and return the result as a new String. The XML/HTML tag may also include valid HTML/XML attributes. All of the following examples are valid: