{quote:text}

Description

Backslash-escapes the apostrophes and backslashes in a string so the result can be placed inside a single-quoted string literal - for example a PHP array entry or an SQL fragment you build up in a template - without an apostrophe in the content closing the literal early. Each apostrophe becomes a backslash followed by the apostrophe, and each backslash becomes two backslashes; every other character is left as it is. The backslashes are doubled first and the apostrophes are escaped second, so a value that already contains a backslash stays correct. quote does not add the surrounding quotes for you and does not touch double quotes - it escapes the content that goes between single quotes, and is not a substitute for proper database parameter binding.

Parameters

text optional default empty string

The string to escape. Every apostrophe in it becomes a backslash followed by the apostrophe, and every backslash becomes two backslashes; all other characters pass through unchanged. The surrounding single quotes are not added for you - quote escapes the content that goes between them.

Examples

test{quote:C#:\Users}
ExpectedC:\\Users
ActualC:\\Users
A backslash becomes two backslashes. The #: is the escaped-colon form: a bare colon would be read as a parameter separator and cut the value off at C, so write #: to keep a literal colon in the text.
test{quote:it's a \ run}
Expectedit\'s a \\ run
Actualit\'s a \\ run
Both special characters are handled in one pass: the apostrophe is prefixed and the backslash is doubled.
test'name' => '{quote:D'Angelo}'
Expected'name' => 'D\'Angelo'
Actual'name' => 'D\'Angelo'
The canonical use: wrap a value that will sit between single quotes (a PHP array entry, an SQL fragment you assemble in a template) so an apostrophe in it cannot close the literal early. In real templates the inner text is usually a field-getter such as a headline value.
test[{quote:}]
Expected[]
Actual[]
With no text, quote returns an empty string. The brackets here only frame the result so the empty output is visible.
test{quote:O'Brien}
ExpectedO\'Brien
ActualO\'Brien
An apostrophe becomes backslash-apostrophe, so the value can sit inside a single-quoted string literal without closing it early.
test{quote:a'b'c}
Expecteda\'b\'c
Actuala\'b\'c
Every apostrophe is escaped, not just the first one.
test{quote:plain text}
Expectedplain text
Actualplain text
When the value has no apostrophes or backslashes, quote returns it unchanged - it only touches those two characters.