Skip to content

Commit

Permalink
siplify
Browse files Browse the repository at this point in the history
  • Loading branch information
erdos committed Nov 15, 2023
1 parent 1f81cf4 commit 8ad96f1
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions java-src/io/github/erdos/stencil/impl/NativeEvaluator.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.erdos.stencil.impl;

import clojure.lang.AFunction;
import clojure.lang.IFn;
import clojure.lang.Keyword;
import clojure.lang.PersistentHashMap;
import io.github.erdos.stencil.EvaluatedDocument;
import io.github.erdos.stencil.PreparedFragment;
Expand Down Expand Up @@ -41,11 +41,10 @@ public EvaluatedDocument render(PreparedTemplate template, Map<String, PreparedF
throw new IllegalArgumentException("Template data is missing!");
}

final IFn fn = ClojureHelper.findFunction("eval-template");
final Object argsMap = makeArgsMap(template.getSecretObject(), fragments, data.getData());

try {
return (EvaluatedDocument) fn.invoke(argsMap);
return (EvaluatedDocument) ClojureHelper.findFunction("eval-template").invoke(argsMap);
} catch (EvalException e) {
throw e;
} catch (Exception e) {
Expand All @@ -62,9 +61,8 @@ public FunctionEvaluator getFunctionEvaluator() {
return functions;
}

@SuppressWarnings("unchecked")
private Object makeArgsMap(Object template, Map<String, PreparedFragment> fragments, Object data) {
final Map result = new HashMap();
final Map<Keyword, Object> result = new HashMap<>();
result.put(ClojureHelper.Keywords.TEMPLATE.kw, template);
result.put(ClojureHelper.Keywords.DATA.kw, data);
result.put(ClojureHelper.Keywords.FUNCTION.kw, new FunctionCaller());
Expand Down

0 comments on commit 8ad96f1

Please sign in to comment.