Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

Text operators

concat and indent from eZTemplateTextOperator - joining values into one string and indenting multi-line text with spaces, tabs or a custom filler, the object trap of concat in compiled templates, with examples rendered…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/template-operators/text-operators.md

On this page

Text operators

The template language has no string concatenation operator such as . or ~; concat does that job. It and indent are registered by eZTemplateTextOperator (lib/eztemplate/classes/eztemplatetextoperator.php) through lib/eztemplate/classes/eztemplateautoload.php.

Contents

  1. concat
  2. indent
  3. Related pages

concat

concat

Joins the piped input (when there is one) and every parameter into one string, in order. Numbers are converted to text.

ParameterTypeRequiredDefault
valuesstring or numbernonone

Input: optional, it comes first. Returns a string. concat does not escape, so wash the result, or each untrusted part, before printing it in HTML. Generated reference: concat.

The example uses the Running topic on a development installation (node 163):

{def $node = fetch( 'content', 'node', hash( 'node_id', 163 ) )}
{concat( 'Topic: ', $node.name, ' (node ', $node.node_id, ')' )|wash}
{'/'|concat( $node.url_alias )}
{concat( 'class ', 'ng-', $node.class_identifier )}

Output:

Topic: Running (node 163)
/running
class ng-ng_topic

Objects. The interpreter (modify()) silently skips a parameter that is an object:

{def $node = fetch( 'content', 'node', hash( 'node_id', 163 ) )}
[{concat( 'object skipped: ', $node )}]

Output:

[object skipped: ]

The compiled form (concatTransformation()) joins the values with PHP's . operator, and PHP cannot turn a node into a string. On a development installation the same template, compiled, stopped with Error: Object of class eZContentObjectTreeNode could not be converted to string and produced no output at all, not even the text before it. Always pass the attribute you mean ($node.name), never the object.

indent

indent

Puts a filler in front of the first line and after every newline of the input.

ParameterTypeRequiredDefault
indent_countintegeryesfalse
indent_typeidentifier: space, tab or customnospace
indent_fillerstring (with custom)nofalse

Any other type gives spaces. A negative count writes the error "The value of the "count" argument is negative" to the debug log and leaves the text unchanged. Returns a string. Useful for plain-text output such as mail bodies; in HTML, whitespace collapses. Generated reference: indent.

{def $text = "line one
line two"}
[{$text|indent( 4 )}]
[{$text|indent( 2, 'custom', '> ' )}]
[{$text|indent( 1, 'tab' )|bin2hex|extract_left( 4 )}] (09 = a tab)

Output:

[    line one
    line two]
[> > line one
> > line two]
[096c] (09 = a tab)

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x