Strings

These documentation pages are no longer maintained. Please visit the new documentation site.

Strings are text encapsulated by a matching pair of either single or double quotes, ' or ". If the quotes are forgotten/omitted, a string will be interpreted either as an identifier or a function name. Strings are usually defined in the following way:

{'This is a string.'}

{"This is also a string."}

It is possible to use quotes inside strings. This can be done in two ways:

  • by using a different kind of quote
  • by using an escape character

In other words, if you need to use a quote inside a string, you can either switch to the other enclosing quote type, or escape the quote character with a backslash. The following examples demonstrate the use of quotes inside strings:

{'The following text is double quoted: "Rock and roll!" '}

{"The following text is single quoted: 'Rock and roll!' "}

{'Using both single and double quotes: "Rock\'n roll!"  '}

{'Using both single and double quotes: \'Rock\'n roll!\' '}

{"Using both single and double quotes: 'Rock'n roll!'   "}

{"Using both single and double quotes: \"Rock'n roll\"  "}

The output of the template code above will be:

The following text is double quoted: "Rock and roll!"
The following text is single quoted: 'Rock and roll!'
Using both single and double quotes: "Rock'n roll!"
Using both single and double quotes: 'Rock'n roll!'
Using both single and double quotes: 'Rock'n roll!'
Using both single and double quotes: "Rock'n roll!"

Because of the way template code is defined (template code is encapsulated in a matching pair of curly brackets), the right curly bracket, "}", must also be prepended by the backslash escape character. The following example demonstrates this:

{'{ This text is inside curly brackets.\}'}

The output of the template code above will be:

{This text is inside curly brackets.}

Template strings do not support inline expansion of variables (as in Perl and PHP). In other words, it is not possible to mix variables into strings. However, the concat operator can be used to append the contents of some variable to a string; which means that the concat operator can be used to build strings that consist of other strings and/or variable contents.

Comments

Contents

The template language

Template code
Curly bracket issues
Comments
Variable types
    Numbers
    Strings
    Booleans
    Arrays
    Objects


Created

27/02/2004
3:34:53 pm
by Balazs Halasy

Last updated

27/02/2004
3:34:53 pm
by Balazs Halasy

Authors

Balazs Halasy



This page is part of the eZ Publish documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.