spullara / mustache.java

Implementation of mustache.js for Java
http://www.javarants.com/the-ideal-web-application-templating-system-b301fa4a1f49
Other
1.9k stars 285 forks source link

Hard coded encoding for all input #138

Open DALDEI opened 9 years ago

DALDEI commented 9 years ago

I have created the beginnings of a 'cli' and api based on mustache.java https://github.com/DALDEI/mustache-cli

This is primarily intended to integrate the API portion into xmlsh as an extension module https://github.com/DALDEI/xmlsh

The first need I have is to use native Jackon Node objects as data, and use mustache template files that produce text serialized JSON.

There are multiple issues I am working through - one I ran into is a hard coded encoding for creating Readers and Writers. The readers use either the system encoding or UTF-8, and I havent found OutputStreamWriters that are not in test code.

To solve the input side I have had to subclass MustacheResolver to override the default encodings. ( xmlsh allows runtime settings for all encodings input and out ). Do you think it is reasonable to provide for a setter for the encoding used for creating Writers in the core code so one need not subclass just for this ? I can make a proposal change and submit a pull request.

spullara commented 9 years ago

It seems reasonable to me to set the input/output encoding on the DefaultMustacheFactory