Use Charset instead of String for Mustache template encoding
The MustacheResourceTemplateLoader previously defined the template encoding as a String, defaulting to "UTF-8". This change replaces the field with a Charset and initializes it with StandardCharsets.UTF_8.
Using Charset improves type safety and aligns with modern Spring Boot standards, while avoiding implicit charset lookup issues.
This would be a breaking change since MustacheResourceTemplateLoader.setCharset(String) is public API. I think we could add an overloaded method at some point and possibly also deprecate org.springframework.boot.mustache.autoconfigure.MustacheProperties.getCharsetName().
@philwebb what needs amendements? Perhaps we can share that with @ddongjunn so they rework their original proposal.
@philwebb Thanks for the feedback!
I’ve updated the PR to add the setCharset(Charset) overload while keeping the existing String-based method for backward compatibility (now deprecated). I also deprecated MustacheProperties.getCharsetName() as suggested.
This keeps the change backward compatible while providing a more type-safe API.
Let me know if you’d like any further adjustments.
This PR is ready to be merged once main switches to 4.1.0-SNAPSHOT.
@ddongjunn thanks for the PR. To be consistent more work was required, see https://github.com/snicoll/spring-boot/commit/65cd92f58cb5b82c6de3b6c1dbd1507143b81c66. When something is deprecated, our code base should not call it anymore. Then searching for the same pattern in the rest of the module for consistency revealed a number of other usages not covered initially. It's all done now and will be merged once we can.
@snicoll Thanks for reviewing and refining the PR. I appreciate the consistency updates and the clear explanation. Glad to hear it will be merged once 4.1.0-SNAPSHOT opens.