JtlTemplate class final

A concrete implementation of Template that stores a template source and a map of attributes to inject during rendering.

JtlTemplate represents a template either as a raw string or as a reference to a file or asset path, along with associated dynamic attributes. It is immutable and suitable for use with TemplateRenderer or the Jetleaf engine.

Features

  • Stores the template as a string or path.
  • Attributes are stored as a map and exposed as an unmodifiable view.
  • Immutable and simple to use for templates with static or dynamic content.

Example Usage

final template = JtlTemplate(
  "templates/homepage.html",
  {"title": "Hello World", "showBanner": true},
);

print(template.getLocation()); // "templates/homepage.html"
print(template.getAttributes()); // {"title": "Hello World", "showBanner": true}

Design Notes

  • _attributes map is wrapped with Map.unmodifiable to prevent external mutation.
  • Template content (_location) is immutable after creation.
  • Can represent either raw content or a path/identifier to an external template.
Implemented types

Constructors

JtlTemplate(String _location, Map<String, Object?> _attributes)
Creates a new JtlTemplate with the given template content and attributes.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

getAttributes() → Map<String, Object?>
Returns a map of dynamic attributes to inject into the template.
override
getLocation() → String
Returns the path or location of the template as a string.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited