Skip to content

TemplateValue

[Source]

A value that can be used in a template. Either a single value or a sequence of values.

When used with HTMLTemplate, values are automatically escaped based on their HTML context. To bypass escaping for trusted content, use the unescaped constructor instead of create.

class box TemplateValue

Constructors

create

[Source]

new box create(
  value: (String val | Seq[TemplateValue box] box),
  properties: Map[String val, TemplateValue box] box = primitive _RawBlock
type _BlockKind is (_RegularBlock | _CommentBlock | _RawBlock)

// A resolved filter argument: either a string literal or a property reference.
type _ResolvedArg is (String | _PropNode)

class _Pipe
  """
  A fully resolved pipe expression ready for rendering. The source — either a
  property reference or a string literal — is piped through each filter in
  order. Each filter has been validated at parse time for existence and correct
  arity.
  """
  let source: (_PropNode | String)
  let filters: Array[(AnyFilter, Array[_ResolvedArg] box)] box

  new box create(
    source': (_PropNode | String),
    filters': Array[(AnyFilter, Array[_ResolvedArg] box)] box
  ) =>
    source = source'
    filters = filters'

class _If
  let value: _PropNode
  let body: Array[_Part] box
  let else_body: (Array[_Part] box | None)

  new box create(
    value': _PropNode,
    body': Array[_Part] box,
    else_body': (Array[_Part] box | None) = None
  ) =>
    value = value'
    body = body'
    else_body = else_body'

class box _IfElse
  """
  Marker on the open-block stack indicating an `if` block that has transitioned
  to its `else` branch. Stores the original condition and if-body so they can
  be assembled into the final `_If` node when `end` is encountered.
  """
  let value: _PropNode
  let if_body: Array[_Part] box

  new box create(value': _PropNode, if_body': Array[_Part] box) =>
    value = value'
    if_body = if_body'

class box _IfNotElse
  """
  Marker on the open-block stack indicating an `ifnot` block that has
  transitioned to its `else` branch. Stores the original condition and if-body
  so they can be assembled into the final `_IfNot` node when `end` is
  encountered.
  """
  let value: _PropNode
  let if_body: Array[_Part] box

  new box create(value': _PropNode, if_body': Array[_Part] box) =>
    value = value'
    if_body = if_body'

class _IfNot
  let value: _PropNode
  let body: Array[_Part] box
  let else_body: (Array[_Part] box | None)

  new box create(
    value': _PropNode,
    body': Array[_Part] box,
    else_body': (Array[_Part] box | None) = None
  ) =>
    value = value'
    body = body'
    else_body = else_body'

class _Loop
  let target: String
  let source: _PropNode
  let body: Array[_Part] box

  new box create(
    target': String,
    source': _PropNode,
    body': Array[_Part] box
  ) =>
    target = target'
    source = source'
    body = body'

class _Block
  let name: String
  let body: Array[_Part] box

  new box create(name': String, body': Array[_Part] box) =>
    name = name'
    body = body'

type _Part is
  ( (_Literal, String) | _Pipe box | _PropNode
  | _If box | _IfNot box | _Loop box | _Block box )

class box TemplateValue
  """
  A value that can be used in a template. Either a single value or a
  sequence of values.

  When used with `HTMLTemplate`, values are automatically escaped based on
  their HTML context. To bypass escaping for trusted content, use the
  `unescaped` constructor instead of `create`.
  """
  let _data: (String | Seq[TemplateValue] box)
  let _properties: Map[String, TemplateValue] box
  let _renderable: RenderableValue

  new box create(
    value: (String | Seq[TemplateValue] box),
    properties: Map[String, TemplateValue] box = Map[String, TemplateValue])
: TemplateValue box^

Parameters

// A resolved filter argument: either a string literal or a property reference. type _ResolvedArg is (String | _PropNode)

class _Pipe """ A fully resolved pipe expression ready for rendering. The source — either a property reference or a string literal — is piped through each filter in order. Each filter has been validated at parse time for existence and correct arity. """ let source: (_PropNode | String) let filters: Array[(AnyFilter, Array[_ResolvedArg] box)] box

new box create( source': (_PropNode | String), filters': Array[(AnyFilter, Array[_ResolvedArg] box)] box ) => source = source' filters = filters'

class _If let value: _PropNode let body: Array[_Part] box let else_body: (Array[_Part] box | None)

new box create( value': _PropNode, body': Array[_Part] box, else_body': (Array[_Part] box | None) = None ) => value = value' body = body' else_body = else_body'

class box _IfElse """ Marker on the open-block stack indicating an if block that has transitioned to its else branch. Stores the original condition and if-body so they can be assembled into the final _If node when end is encountered. """ let value: _PropNode let if_body: Array[_Part] box

new box create(value': _PropNode, if_body': Array[_Part] box) => value = value' if_body = if_body'

class box _IfNotElse """ Marker on the open-block stack indicating an ifnot block that has transitioned to its else branch. Stores the original condition and if-body so they can be assembled into the final _IfNot node when end is encountered. """ let value: _PropNode let if_body: Array[_Part] box

new box create(value': _PropNode, if_body': Array[_Part] box) => value = value' if_body = if_body'

class _IfNot let value: _PropNode let body: Array[_Part] box let else_body: (Array[_Part] box | None)

new box create( value': _PropNode, body': Array[_Part] box, else_body': (Array[_Part] box | None) = None ) => value = value' body = body' else_body = else_body'

class _Loop let target: String let source: _PropNode let body: Array[_Part] box

new box create( target': String, source': _PropNode, body': Array[_Part] box ) => target = target' source = source' body = body'

class _Block let name: String let body: Array[_Part] box

new box create(name': String, body': Array[_Part] box) => name = name' body = body'

type _Part is ( (_Literal, String) | _Pipe box | _PropNode | _If box | _IfNot box | _Loop box | _Block box )

class box TemplateValue """ A value that can be used in a template. Either a single value or a sequence of values.

When used with HTMLTemplate, values are automatically escaped based on their HTML context. To bypass escaping for trusted content, use the unescaped constructor instead of create. """ let _data: (String | Seq[TemplateValue] box) let _properties: Map[String, TemplateValue] box let _renderable: RenderableValue

new box create( value: (String | Seq[TemplateValue] box), properties: Map[String, TemplateValue] box = Map[String, TemplateValue]

Returns


unescaped

[Source]

Create a value that bypasses HTML auto-escaping in HTMLTemplate. The content is inserted as-is, without context-aware escaping. Use this only for content you trust (e.g., pre-sanitized HTML fragments).

Has no effect when used with plain Template, which does not escape.

Note: the unescaped annotation applies only to direct variable substitution ({{ name }}). When a value passes through a filter pipe ({{ name | upper }}), the result is always escaped — filters could introduce unsafe content.

new box unescaped(
  value: (String val | Seq[TemplateValue box] box),
  properties: Map[String val, TemplateValue box] box = primitive _RawBlock
type _BlockKind is (_RegularBlock | _CommentBlock | _RawBlock)

// A resolved filter argument: either a string literal or a property reference.
type _ResolvedArg is (String | _PropNode)

class _Pipe
  """
  A fully resolved pipe expression ready for rendering. The source — either a
  property reference or a string literal — is piped through each filter in
  order. Each filter has been validated at parse time for existence and correct
  arity.
  """
  let source: (_PropNode | String)
  let filters: Array[(AnyFilter, Array[_ResolvedArg] box)] box

  new box create(
    source': (_PropNode | String),
    filters': Array[(AnyFilter, Array[_ResolvedArg] box)] box
  ) =>
    source = source'
    filters = filters'

class _If
  let value: _PropNode
  let body: Array[_Part] box
  let else_body: (Array[_Part] box | None)

  new box create(
    value': _PropNode,
    body': Array[_Part] box,
    else_body': (Array[_Part] box | None) = None
  ) =>
    value = value'
    body = body'
    else_body = else_body'

class box _IfElse
  """
  Marker on the open-block stack indicating an `if` block that has transitioned
  to its `else` branch. Stores the original condition and if-body so they can
  be assembled into the final `_If` node when `end` is encountered.
  """
  let value: _PropNode
  let if_body: Array[_Part] box

  new box create(value': _PropNode, if_body': Array[_Part] box) =>
    value = value'
    if_body = if_body'

class box _IfNotElse
  """
  Marker on the open-block stack indicating an `ifnot` block that has
  transitioned to its `else` branch. Stores the original condition and if-body
  so they can be assembled into the final `_IfNot` node when `end` is
  encountered.
  """
  let value: _PropNode
  let if_body: Array[_Part] box

  new box create(value': _PropNode, if_body': Array[_Part] box) =>
    value = value'
    if_body = if_body'

class _IfNot
  let value: _PropNode
  let body: Array[_Part] box
  let else_body: (Array[_Part] box | None)

  new box create(
    value': _PropNode,
    body': Array[_Part] box,
    else_body': (Array[_Part] box | None) = None
  ) =>
    value = value'
    body = body'
    else_body = else_body'

class _Loop
  let target: String
  let source: _PropNode
  let body: Array[_Part] box

  new box create(
    target': String,
    source': _PropNode,
    body': Array[_Part] box
  ) =>
    target = target'
    source = source'
    body = body'

class _Block
  let name: String
  let body: Array[_Part] box

  new box create(name': String, body': Array[_Part] box) =>
    name = name'
    body = body'

type _Part is
  ( (_Literal, String) | _Pipe box | _PropNode
  | _If box | _IfNot box | _Loop box | _Block box )

class box TemplateValue
  """
  A value that can be used in a template. Either a single value or a
  sequence of values.

  When used with `HTMLTemplate`, values are automatically escaped based on
  their HTML context. To bypass escaping for trusted content, use the
  `unescaped` constructor instead of `create`.
  """
  let _data: (String | Seq[TemplateValue] box)
  let _properties: Map[String, TemplateValue] box
  let _renderable: RenderableValue

  new box create(
    value: (String | Seq[TemplateValue] box),
    properties: Map[String, TemplateValue] box = Map[String, TemplateValue]
  ) =>
    _data = value
    _properties = properties
    _renderable = _HTMLEscapingRenderer

  new box unescaped(
    value: (String | Seq[TemplateValue] box),
    properties: Map[String, TemplateValue] box = Map[String, TemplateValue])
: TemplateValue box^

Parameters

// A resolved filter argument: either a string literal or a property reference. type _ResolvedArg is (String | _PropNode)

class _Pipe """ A fully resolved pipe expression ready for rendering. The source — either a property reference or a string literal — is piped through each filter in order. Each filter has been validated at parse time for existence and correct arity. """ let source: (_PropNode | String) let filters: Array[(AnyFilter, Array[_ResolvedArg] box)] box

new box create( source': (_PropNode | String), filters': Array[(AnyFilter, Array[_ResolvedArg] box)] box ) => source = source' filters = filters'

class _If let value: _PropNode let body: Array[_Part] box let else_body: (Array[_Part] box | None)

new box create( value': _PropNode, body': Array[_Part] box, else_body': (Array[_Part] box | None) = None ) => value = value' body = body' else_body = else_body'

class box _IfElse """ Marker on the open-block stack indicating an if block that has transitioned to its else branch. Stores the original condition and if-body so they can be assembled into the final _If node when end is encountered. """ let value: _PropNode let if_body: Array[_Part] box

new box create(value': _PropNode, if_body': Array[_Part] box) => value = value' if_body = if_body'

class box _IfNotElse """ Marker on the open-block stack indicating an ifnot block that has transitioned to its else branch. Stores the original condition and if-body so they can be assembled into the final _IfNot node when end is encountered. """ let value: _PropNode let if_body: Array[_Part] box

new box create(value': _PropNode, if_body': Array[_Part] box) => value = value' if_body = if_body'

class _IfNot let value: _PropNode let body: Array[_Part] box let else_body: (Array[_Part] box | None)

new box create( value': _PropNode, body': Array[_Part] box, else_body': (Array[_Part] box | None) = None ) => value = value' body = body' else_body = else_body'

class _Loop let target: String let source: _PropNode let body: Array[_Part] box

new box create( target': String, source': _PropNode, body': Array[_Part] box ) => target = target' source = source' body = body'

class _Block let name: String let body: Array[_Part] box

new box create(name': String, body': Array[_Part] box) => name = name' body = body'

type _Part is ( (_Literal, String) | _Pipe box | _PropNode | _If box | _IfNot box | _Loop box | _Block box )

class box TemplateValue """ A value that can be used in a template. Either a single value or a sequence of values.

When used with HTMLTemplate, values are automatically escaped based on their HTML context. To bypass escaping for trusted content, use the unescaped constructor instead of create. """ let _data: (String | Seq[TemplateValue] box) let _properties: Map[String, TemplateValue] box let _renderable: RenderableValue

new box create( value: (String | Seq[TemplateValue] box), properties: Map[String, TemplateValue] box = Map[String, TemplateValue] ) => _data = value _properties = properties _renderable = _HTMLEscapingRenderer

new box unescaped( value: (String | Seq[TemplateValue] box), properties: Map[String, TemplateValue] box = Map[String, TemplateValue]

Returns


Public Functions

apply

[Source]

fun box apply(
  name: String val)
: TemplateValue box ?

Parameters

Returns


string

[Source]

fun box string()
: String val ?

Returns


renderable

[Source]

The rendering strategy for this value. HTMLTemplate calls this to determine how to escape the value based on HTML context.

fun box renderable()
: RenderableValue val

Returns


values

[Source]

fun box values()
: Iterator[TemplateValue box] ref

Returns