Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ChunkResolver to partially resolve expressions #525

Merged
merged 11 commits into from
Nov 17, 2020
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