renderTemplate top-level property

TemplateRenderer renderTemplate
getter/setter pair

Can be set to define a custom rendering function to handle your template files and use any templating language of your choice.

Uses Mustache templates by default.

Implementation

TemplateRenderer renderTemplate =
    (final String? source, final Map<dynamic, dynamic> options, final PartialsResolver resolver) {
  final template = mustache.Template(source ?? '', htmlEscapeValues: false, partialResolver: resolver, lenient: true);

  final inFormat = 'yyyy-MM-dd';

  formatDate(mustache.LambdaContext ctx) => _parseDate(ctx.renderString(), inFormat, _outputFormat);

  options['formatDate'] = formatDate;

  // print('===render: $source \n with opts:$options');

  return template.renderString(options);
};