Skip to content

Commit

Permalink
Merge pull request #525 from jasmith-hs/chunk-resolver
Browse files Browse the repository at this point in the history
Add ChunkResolver to partially resolve expressions
  • Loading branch information
jasmith-hs authored Nov 17, 2020
2 parents 5278aa4 + ad4b922 commit 9808515
Show file tree
Hide file tree
Showing 5 changed files with 628 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/main/java/com/hubspot/jinjava/interpret/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public enum Library {
private final Stack<String> renderStack = new Stack<>();

private boolean validationMode = false;
private boolean hideInterpreterErrors = false;

public Context() {
this(null, null, null);
Expand Down Expand Up @@ -526,4 +527,12 @@ public void addDependencies(SetMultimap<String, String> dependencies) {
public SetMultimap<String, String> getDependencies() {
return this.dependencies;
}

public boolean getHideInterpreterErrors() {
return hideInterpreterErrors;
}

public void setHideInterpreterErrors(boolean hideInterpreterErrors) {
this.hideInterpreterErrors = hideInterpreterErrors;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.hubspot.jinjava.objects.date;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import java.time.format.DateTimeFormatter;

public class JsonPyishDateSerializer extends JsonSerializer<PyishDate> {

@Override
public void serialize(
PyishDate pyishDate,
JsonGenerator jsonGenerator,
SerializerProvider serializerProvider
)
throws IOException {
jsonGenerator.writeString(
DateTimeFormatter
.ofPattern(PyishDate.PYISH_DATE_FORMAT)
.format(pyishDate.toDateTime())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
public final class PyishDate extends Date implements Serializable, PyWrapper {
private static final long serialVersionUID = 1L;
public static final String PYISH_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";

private final ZonedDateTime date;

Expand Down Expand Up @@ -102,7 +103,7 @@ public ZonedDateTime toDateTime() {

@Override
public String toString() {
return strftime("yyyy-MM-dd HH:mm:ss");
return strftime(PYISH_DATE_FORMAT);
}

@Override
Expand Down
Loading

0 comments on commit 9808515

Please sign in to comment.