This page is itself a LaiRu template. Everything you see is the rendered output of a .lasso file — text passes through and bracket expressions are evaluated.

Template File Types

LaiRu renders files with the extensions .lasso, .lasso9, and .lp. Any other file is served as a static asset. When a request targets a directory, LaiRu tries index.lasso, index.lasso9, index.lp, then index.html in order.

Bracket Tags

Code between [ and ] is evaluated as a Lasso expression. The result is inserted into the output unless it is void or null. Assignments and declarations produce no output.

Hello [local(name) = 'Ada'][#name]!
<!-- renders: Hello Ada! -->

<p>2 + 3 = [2 + 3]</p>
<!-- renders: <p>2 + 3 = 5</p> -->

Processing-instruction Delimiters

LaiRu also recognises the <?lasso … ?> and <?= … ?> delimiters:

<?lasso
  local(count) = 0
  loop(3) => { count = count + 1 }
?>
<p><?= #count ?> iterations.</p>
<!-- renders: <p>3 iterations.</p> -->

LDML Page-control Tags

LaiRu supports the legacy LDML bracket tags used in historic Lasso pages. These sit alongside the modern bracket-expression form.

if / else / /if

[if(#hour < 12)]
  Good morning!
[else(#hour < 17)]
  Good afternoon!
[else]
  Good evening!
[/if]

loop / /loop

[loop(5)]
  Row [loop_count]
[/loop]

no_square_brackets

The [no_square_brackets] tag disables bracket interpretation for the remainder of the template, allowing literal square brackets in the output:

[no_square_brackets]
[this text is now literal and not evaluated]

Relative Includes

Use [include('path')] to embed another template file. The path is resolved relative to the including file’s location, not the document root. Includes are sandboxed to the template root and recursive include chains are rejected.

<!-- from /pages/article.lasso -->
[include('../includes/header.lasso')]
<main> ... </main>
[include('../includes/footer.lasso')]

Variables in Templates

Template includes share the same variable space as the including file. Use thread variables ($name) to pass values into includes:

<!-- mypage.lasso -->
[$page_title = 'My Page']
[include('../includes/header.lasso')]
<main>...</main>
[include('../includes/footer.lasso')]

<!-- includes/header.lasso -->
<title>[$page_title]</title>

Response Control in Templates

Templates can set HTTP response properties before any output is written:

[response_status(201)]
[response_header('X-Powered-By', 'LaiRu')]
[response_content_type('application/json')]
[response_cookie('theme', 'dark', -httpOnly, -path='/')]
[response_no_cache]

Source and Parse Caching

The LaiRu service caches template source by path, length, and mtime. Parsed Lasso code fragments are cached by source text. Diagnostics from cached fragments are remapped to the active template source coordinates after reuse. Disable caching with LAIRU_TEMPLATE_CACHE=0 and LAIRU_PARSE_CACHE=0.