Template delimiters

Square bracket LDML tags, processing instruction tags, and expression tags invoke LaiRu inside literal output.

Target guide

Plain text is output as written until a LaiRu delimiter is encountered. The square bracket form is compact and common in legacy templates. The processing-instruction form is useful in HTML, XML, JavaScript, and CSS files where literal square brackets may appear often. The expression form writes a single expression result directly into the output stream.

A code block can open in one tag, emit literal text, and resume in a later tag. That pattern is how templates keep HTML structure readable while still using conditionals and loops.

Place [no_square_brackets] outside any tag to treat later square brackets as ordinary text in that file. After that point, use processing-instruction delimiters for server-side code.

Examples

Working pattern

1[if(web_request->param('ok')) => {]2<p>Ready</p>3[else]4<p>Not ready</p>5[}]
Use this as a focused starting point and adapt it in context.

Square bracket code block inside HTML

1<ul>2[with name in array('Ada', 'Grace') do => {]3  <li>[#name->encodeHtml]</li>4[}]5</ul>
Square brackets are convenient in ordinary templates because they are short and can span HTML. Use balanced code tags when a block opens before literal output and closes after it.

Processing instruction block

1<?lasso2local(title) = 'Status'3local(ok) = true4?>5<h1><?= #title->encodeHtml ?></h1>6<?lasso if(#ok) => { ?>7<p>Ready</p>8<?lasso } ?>
Processing-instruction delimiters are useful in files that contain many JavaScript arrays or CSS selectors where literal square brackets would be noisy.

Expression delimiter for a single value

1<p>Rendered at <?= date->format('%Y-%m-%d %H:%M:%S') ?></p>
The expression form writes the result of one expression directly into the output stream.

Disable square bracket parsing for the rest of a file

1[no_square_brackets]2<script>3  const names = ['Ada', 'Grace'];4</script>5<?lasso6// Use PI delimiters after square brackets have been disabled.7'done'8?>
Once disabled in a file, square bracket parsing stays disabled for that file. Use PI delimiters for later LaiRu code.
Comments
frontend.edgecase@[domain removed for privacy]

If a page has a lot of JavaScript array literals, put [no_square_brackets] before the script section and use PI delimiters for any later server-side values.

1[no_square_brackets]2<script>3  const ids = [1, 2, 3];4</script>5<?= date ?>

Related