From 38b50a5902272890ae4b601732cea18f7d7cf681 Mon Sep 17 00:00:00 2001 From: Aaron Segal Date: Thu, 16 Nov 2023 13:19:57 -0500 Subject: [PATCH] Removed unnecessary method and formalized default case for non-number args --- .../jinjava/interpret/JinjavaInterpreter.java | 18 +++--------------- .../jinjava/lib/filter/RenderFilter.java | 9 ++++++++- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/hubspot/jinjava/interpret/JinjavaInterpreter.java b/src/main/java/com/hubspot/jinjava/interpret/JinjavaInterpreter.java index 2e66bd233..d127f597d 100644 --- a/src/main/java/com/hubspot/jinjava/interpret/JinjavaInterpreter.java +++ b/src/main/java/com/hubspot/jinjava/interpret/JinjavaInterpreter.java @@ -267,7 +267,7 @@ public String render(String template, long renderLimit) { } /** - * Render the given root node, processing extend parents. Equivalent to render(root, true, -1) + * Render the given root node, processing extend parents. Equivalent to render(root, true) * * @param root * node to render @@ -279,7 +279,7 @@ public String render(Node root) { /** * Render the given root node with an option to process extend parents. - * Equivalent to render(root, processExtendRoots, -1). + * Equivalent to render(root, processExtendRoots). * @param root * node to render * @param processExtendRoots @@ -289,18 +289,6 @@ public String render(Node root, boolean processExtendRoots) { return render(root, processExtendRoots, config.getMaxOutputSize()); } - /** - * Render the given root node to a certain limit, processing extend parents. - * @param root - * node to render - * @param renderLimit - * the number of characters in response text - * @return - */ - public String render(Node root, long renderLimit) { - return render(root, true, renderLimit); - } - /** * Render the given root node using this interpreter's current context * @@ -312,7 +300,7 @@ public String render(Node root, long renderLimit) { * the number of characters the result may contain * @return rendered result */ - public String render(Node root, boolean processExtendRoots, long renderLimit) { + private String render(Node root, boolean processExtendRoots, long renderLimit) { OutputList output = new OutputList(renderLimit); for (Node node : root.getChildren()) { lineNumber = node.getLineNumber(); diff --git a/src/main/java/com/hubspot/jinjava/lib/filter/RenderFilter.java b/src/main/java/com/hubspot/jinjava/lib/filter/RenderFilter.java index 405148d40..4cd6763cb 100644 --- a/src/main/java/com/hubspot/jinjava/lib/filter/RenderFilter.java +++ b/src/main/java/com/hubspot/jinjava/lib/filter/RenderFilter.java @@ -1,5 +1,6 @@ package com.hubspot.jinjava.lib.filter; +import com.hubspot.jinjava.JinjavaConfig; import com.hubspot.jinjava.doc.annotations.JinjavaDoc; import com.hubspot.jinjava.doc.annotations.JinjavaParam; import com.hubspot.jinjava.doc.annotations.JinjavaSnippet; @@ -27,7 +28,13 @@ public String getName() { public Object filter(Object var, JinjavaInterpreter interpreter, String... args) { if (args.length > 0) { String firstArg = args[0]; - return interpreter.render(Objects.toString(var), NumberUtils.toLong(firstArg, 0)); + return interpreter.render( + Objects.toString(var), + NumberUtils.toLong( + firstArg, + JinjavaConfig.newBuilder().build().getMaxOutputSize() + ) + ); } return interpreter.render(Objects.toString(var)); }