Skip to content

Commit

Permalink
Added a setLoader method
Browse files Browse the repository at this point in the history
  • Loading branch information
mbosecke committed Dec 18, 2013
1 parent be00e2f commit 1e3f09b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/main/java/com/mitchellbosecke/pebble/PebbleEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class PebbleEngine {
/*
* Major components
*/
private final Loader loader;
private Loader loader;
private final Parser parser;
private final Lexer lexer;
private final Compiler compiler;
Expand Down Expand Up @@ -83,8 +83,8 @@ public class PebbleEngine {
private Map<String, Operator> binaryOperators;
private Map<String, Filter> filters;
private Map<String, Test> tests;

public PebbleEngine() {
public PebbleEngine(){
this(null);
}

Expand Down Expand Up @@ -118,6 +118,11 @@ public PebbleEngine(Loader loader) {
* @throws LoaderException
*/
public PebbleTemplate loadTemplate(String templateName) throws SyntaxException, LoaderException, PebbleException {

if(this.loader == null){
throw new LoaderException("Loader has not yet been specified.");
}

String className = this.getTemplateClassName(templateName);
PebbleTemplate instance;

Expand Down Expand Up @@ -185,6 +190,10 @@ private String compile(Node node) {
return getCompiler().compile(node).getSource();
}

public void setLoader(Loader loader){
this.loader = loader;
}

public Loader getLoader() {
return loader;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public String getSource(String templateName) throws LoaderException {
return source;
}

private Reader getReader(String templateName) throws LoaderException {
protected Reader getReader(String templateName) throws LoaderException {

Reader reader = readerCache.containsKey(templateName) ? readerCache.get(templateName) : null;

Expand Down

0 comments on commit 1e3f09b

Please sign in to comment.