Skip to content

Commit

Permalink
Removed unnecessary method and formalized default case for non-number…
Browse files Browse the repository at this point in the history
… args
  • Loading branch information
asegal-hs committed Nov 16, 2023
1 parent 09f051b commit 38b50a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
*
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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));
}
Expand Down

0 comments on commit 38b50a5

Please sign in to comment.