TemplateEngine class
A powerful, Laravel Blade-inspired templating engine for Dart.
Supports layouts, includes, control structures, and secure interpolation.
Example:
final engine = TemplateEngine(
viewsDirectory: 'views',
publicDirectory: 'public',
);
final html = engine.render('users.profile', {
'user': user,
'title': 'User Profile'
});
Constructors
- TemplateEngine({required String viewsDirectory, required String publicDirectory})
- Creates a new template engine instance.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- publicDirectory → String
-
Public assets directory (not used directly by engine).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shouldCache ↔ bool
-
Whether to enable template caching.
getter/setter pair
- viewsDirectory → String
-
Directory containing
.htmlview templates.final
Methods
-
clearCache(
) → void - Clears the internal template cache.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
render(
String templateName, [Map< String, dynamic> ? data]) → String - Renders a template with the provided data.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited