Merge pull request #62 from meros/master

Close readers provided by TemplateLoader.
This commit is contained in:
Michael Bayne
2015-03-06 12:14:55 -08:00
@@ -273,7 +273,8 @@ public class Mustache
/** Handles loading partial templates. */ /** Handles loading partial templates. */
public interface TemplateLoader public interface TemplateLoader
{ {
/** Returns a reader for the template with the supplied name. /** Returns a reader for the template with the supplied name.
* Reader will be closed by callee.
* @throws Exception if the template could not be loaded for any reason. */ * @throws Exception if the template could not be loaded for any reason. */
Reader getTemplate (String name) throws Exception; Reader getTemplate (String name) throws Exception;
} }
@@ -741,7 +742,9 @@ public class Mustache
// itself (see issue #13) // itself (see issue #13)
if (_template == null) { if (_template == null) {
try { try {
_template = _comp.compile(_comp.loader.getTemplate(_name)); Reader t = _comp.loader.getTemplate(_name);
_template = _comp.compile(t);
t.close();
} catch (Exception e) { } catch (Exception e) {
if (e instanceof RuntimeException) { if (e instanceof RuntimeException) {
throw (RuntimeException)e; throw (RuntimeException)e;