Skip to content

Commit 0dfc420

Browse files
committed
simplify the api for compiling
1 parent eac634e commit 0dfc420

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

handlebar/src/main/java/com/sampullara/mustache/Handlebar.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import java.io.OutputStream;
2525
import java.util.HashMap;
2626
import java.util.Map;
27-
import java.util.Stack;
28-
import java.util.concurrent.atomic.AtomicInteger;
2927

3028
/**
3129
* Run a local server and merge .js and .html files using mustache.
@@ -73,7 +71,7 @@ public void handle(String s, Request r, HttpServletRequest req, HttpServletRespo
7371
// Handle like a template
7472
String filename = pathInfo.endsWith("/") ? pathInfo + "index.html" : pathInfo.substring(1);
7573
try {
76-
Mustache mustache = mc.compile(new BufferedReader(new FileReader(filename)), new Stack<String>(), new AtomicInteger(0), Handlebar.class.getClassLoader());
74+
Mustache mustache = mc.compile(new BufferedReader(new FileReader(filename)));
7775
FutureWriter fw = new FutureWriter(res.getWriter());
7876
File file = new File(mocks, base + ".json");
7977
res.setStatus(HttpServletResponse.SC_OK);

src/main/java/com/sampullara/mustache/MustacheCompiler.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ public synchronized Mustache parseFile(String path) throws MustacheException {
8585
return result;
8686
}
8787

88+
public Mustache compile(BufferedReader br) throws MustacheException {
89+
return compile(br, new Stack<String>(), new AtomicInteger(0), getClass().getClassLoader());
90+
}
91+
8892
public Mustache compile(BufferedReader br, Stack<String> scope, AtomicInteger currentLine, ClassLoader parent) throws MustacheException {
8993
Mustache result;
9094
StringBuilder code = new StringBuilder();

0 commit comments

Comments
 (0)