Skip to content

Commit

Permalink
Stubs out filters
Browse files Browse the repository at this point in the history
  • Loading branch information
asegal-hs committed Nov 3, 2023
1 parent f3b8912 commit 8fcd5ef
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/main/java/com/hubspot/jinjava/lib/filter/CloseHtmlFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.hubspot.jinjava.lib.filter;

import com.hubspot.jinjava.doc.annotations.JinjavaDoc;
import com.hubspot.jinjava.doc.annotations.JinjavaParam;
import com.hubspot.jinjava.doc.annotations.JinjavaSnippet;
import com.hubspot.jinjava.interpret.JinjavaInterpreter;

@JinjavaDoc(
value = "Closes open HTML tags in a string",
input = @JinjavaParam(value = "s", desc = "String to close", required = true),
snippets = {
@JinjavaSnippet(
code = "{{ \"<p> Hello, world\"|closehtml }}"
)
}
)
public class CloseHtmlFilter implements Filter{

@Override
public String getName() {
return "render";
}

@Override
public Object filter(Object var, JinjavaInterpreter interpreter, String... args) {
/*
Closes open HTML tags.
*/

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public String getName() {

@Override
public Object filter(Object var, JinjavaInterpreter interpreter, String... args) {
if (args.length > 0) {
/*
This means a render limit length has been provided.
Here we begin a left to right render where we add to an HTML string until the length reaches a certain limit.
*/
}
return interpreter.render(Objects.toString(var));
}
}

0 comments on commit 8fcd5ef

Please sign in to comment.