Skip to main content

Template Syntax

ST4 Group File

// Change delimiters for template file
delimiters "$", "$"
// Template
template(a1, a2, ...) ::= <<
content
>>
// Ignore newlines, leading and trailing whitespace
template(a1, a2, ...) ::= <%
content
%>
// One-line template
template(a1, a2, ...) ::= "content"

ST4 Syntax

<value> // insert value
<value.prop> // insert property
<template(a1, a2)> // call template

/* Conditional */
<if(expr1)>content1
<elseif(expr2)>content2
<else>content3
<endif>

/* Iterations */
// Apply template to each item
<list:template();separator="sep">
// Anonymous template
<list:{item | expr};separator="sep">

/* Escape characters */
\<, \> // escape delimiters
<\ >, <\n>, <\t> // explicit whitespace characters
<\\> // ignore next newline
<! comment !>

NSX String formats

<s1.upper>, <s1.toUpper> // uppercase
<s1.lower>, <s1.toLower> // lowercase
<s1.firstToUpper>, <s1.firstToLower>
<s1.prettyString> // camelCase/dashes to spaces
<s1.asPath> // package to path
<s1.asCamelCase>, <s1.asSnakeCase>, <s1.asPascalCase>
<s1.asKebab>, <s1.asKebabCase>
<s1;format="escaped"> // Escapes \ characters
<s1;format="htmlEscaped"> // Escape some HTML chars

NSX Anchors

/* Anchors for testing */
// anchor:fields:start
content
// anchor:fields:end

/* Anchor for Features */
@anchor:fields
@anchor:fields(opt1, opt2, ...)

/* Hook into Feature Anchor */
@hook:fields:start
content
@hook:fields:end

/* Custom Anchor */
@custom:methods

/* Insert import code */
@imports
@imports(Services) // secondary imports anchor