package nl.veenm.paypoint.service; import jakarta.enterprise.context.ApplicationScoped; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.Map; @ApplicationScoped public class EmailTemplateService { public String loadTemplate(String templatePath, Map replacements) { try (InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream(templatePath)) { if (is == null) { throw new RuntimeException("Kon e-mailtemplate niet vinden!"); } String template = new String(is.readAllBytes(), StandardCharsets.UTF_8); for (Map.Entry entry : replacements.entrySet()) { template = template.replace("{{" + entry.getKey() + "}}", entry.getValue()); } return template; } catch (IOException e) { throw new RuntimeException("Kon e-mailtemplate niet inladen: " + templatePath, e); } } }