templating library

Server-rendered HTML: a template seam, an adapter, and the response helpers.

import 'package:dust_server/templating.dart';

final templates = MustacheTemplates.fromDirectory('web/templates');

Future<Response> page(Request request) async =>
    render(templates, 'todos/index', {'todos': todos});

The adapter is over mustache_template; implement TemplateEngine to use anything else. Everything here is also exported from package:dust_server/server.dart.

Classes

MustacheTemplates
A TemplateEngine over mustache_template.
TemplateEngine
Renders a named template against a set of values.

Functions

htmlResponse(String markup, {int status = 200}) Response
Answers with markup as an HTML document.
render(TemplateEngine engine, String template, Map<String, Object?> values, {int status = 200}) Response
Renders template with values and answers with the result.

Exceptions / Errors

TemplateNotFound
A template nobody registered.