s:trim #

Use s:trim on an element when indentation/newline-only text nodes between children should be removed at compile time.

This is useful for compact inline outputs such as <title>, where line breaks from template formatting would otherwise be preserved.

<title s:trim>
    <s-template s:if="$hasPageTitle">Glaze Documentation | </s-template>
    <?= $siteTitle ?>
</title>
<!-- $hasPageTitle = true, $siteTitle = 'Glaze' -->
<title>Glaze Documentation | Glaze</title>

Notes:

  • s:trim removes only whitespace-only child text nodes.
  • Tabs/newlines in trimmed text nodes are compacted to single spaces.
  • Leading/trailing whitespace in the trimmed subtree is removed.
  • Non-whitespace text and other child nodes are preserved.
  • s:trim is supported on HTML elements only.
  • s:trim is presence-only and does not accept a value.
  • The s:trim attribute itself is not rendered in final HTML.