jtl library

🌿 JetLeaf Template Engine (JTL)

The JetLeaf Template Language (JTL) provides a flexible and efficient template engine for JetLeaf applications. It supports:

  • template parsing and rendering
  • source code management
  • filters for content transformation
  • caching for optimized template reuse

This library exposes all core components required for template management and rendering in a JetLeaf-based application.

πŸ”‘ Key Concepts

πŸ“„ Source Code Management

  • _source_code.dart / source_code.dart β€” manage template source code, including storage, retrieval, and preprocessing

πŸ— Template Parsing & Rendering

  • _template.dart / template.dart β€” core template representation, parsing logic, and rendering engine

πŸ›  Filter Registry

  • filter_registry.dart β€” register and manage template filters for transforming template variables during rendering

⚑ Template Caching

  • template_cache.dart β€” caching layer to store precompiled or frequently used templates for performance optimization

🎯 Intended Usage

Import this library to enable template-based rendering in JetLeaf:

import 'package:jtl/jtl.dart';

final template = Template.fromString('Hello, {{name}}!');
final output = template.render({'name': 'JetLeaf'});
print(output); // Hello, JetLeaf!

Supports dynamic template evaluation, reusable filters, and efficient caching for high-performance applications.

Β© 2025 Hapnium & JetLeaf Contributors

Classes

CodeElement
Represents a single element or fragment of code within a CodeStructure.
CodeStructure
Represents the hierarchical structure of a source code file.
CodeStructureBuilder
Builder for constructing a CodeStructure using a fluent API.
ConditionalStatement
Represents a conditional (if) statement in a template or code structure.
ConfigurableJtl
An extension of Jtl that provides full runtime configurability for the JetLeaf template engine, allowing developers to customize or replace all core components that affect template rendering.
DefaultCodeStructure
Default implementation of CodeStructure, representing a hierarchical structure of code elements within a template or source file.
DefaultExpressionEvaluator
Default implementation of TemplateExpressionEvaluator, capable of evaluating template expressions in a given TemplateContext.
DefaultSourceCode
Represents the concrete implementation of SourceCode, encapsulating an asset, its code structure, raw content, and rendered content.
DefaultTemplateContext
Default implementation of TemplateContext, representing the context in which a template is rendered.
DefaultTemplateRenderer
A template renderer that converts Template instances into fully-rendered source code strings (SourceCode) using context-aware processing, variable substitution, conditionals, loops, and filters.
DefaultVariableResolver
Default implementation of TemplateVariableResolver, providing variable resolution from a flat or nested map of values.
ForEachStatement
Represents a loop statement (each block) within a template or code structure.
HtmlTagElement
Represents an HTML tag element within a CodeStructure, including optional opening and closing tags, content, and nested child elements.
IncludeStatement
Represents an include statement in a template, which imports or embeds another template within the current template.
InMemoryTemplateCache
An in-memory implementation of TemplateCache that stores rendered templates in a simple Map<String, SourceCode>.
Jtl
The core JetLeaf template engine interface, providing access to template rendering, caching, variable resolution, expression evaluation, filters, and asset sourcing.
JtlFactory
A concrete, fully configurable factory for the JetLeaf template engine, implementing ConfigurableJtl and providing a complete, ready-to-use template engine instance.
JtlTemplate
A concrete implementation of Template that stores a template source and a map of attributes to inject during rendering.
SourceCode
Represents the output of a template rendering or code generation process.
SourceCodeBuilder
Builder for constructing a SourceCode instance using a fluent API.
Statement
Represents a code statement within a CodeStructure or template.
Template
Represents an abstract template source that can be rendered by a TemplateRenderer using a set of dynamic attributes or a TemplateContext.
TemplateCache
An interface for caching rendered templates to improve performance and reduce repeated parsing/rendering of template content.
TemplateContext
Represents the runtime context for a template, providing the mechanisms to resolve variables and evaluate expressions during template rendering.
TemplateExpressionEvaluator
Evaluates expressions in the context of a template, returning a boolean result that indicates whether the expression is truthy.
TemplateFilterRegistry
Registry for template filters that transform or process values during template rendering.
TemplateRenderer
An interface for rendering templates into fully-formed SourceCode using a given TemplateContext.
TemplateVariableResolver
Resolves template variable names into their string representations at runtime during template rendering.
TextCodeElement
Represents a plain text element within a CodeStructure.

Typedefs

TemplateFilter = Object? Function(Object? value)
Represents a filter function that transforms a value in a template.