render method

String render(
  1. String templateContent,
  2. Map<String, String> placeholders
)

Replaces placeholders formatted as {{KEY}} with their matching values from placeholders.

Implementation

String render(String templateContent, Map<String, String> placeholders) {
  try {
    var result = templateContent;
    placeholders.forEach((key, value) {
      result = result.replaceAll('{{$key}}', value);
    });
    return result;
  } catch (e) {
    throw TemplateException('Failed to render template placeholders', e);
  }
}