Skip to content

Commit

Permalink
revert old previous change that breaks backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
msangel committed Apr 6, 2024
1 parent d8b276c commit b5aac74
Show file tree
Hide file tree
Showing 92 changed files with 165 additions and 167 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ You can do that as follows:
// first create template parser with new filter
TemplateParser parser = new TemplateParser.Builder().withFilter(new Filter("b") {
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {
// create a string from the value
String text = super.asString(value, context);

Expand All @@ -218,7 +218,7 @@ And to use an optional parameter in your filter, do something like this:
// first create template parser with your filter
TemplateParser parser = new TemplateParser.Builder().withFilter(new Filter("repeat"){
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {
// get the text of the value
String text = super.asString(value, context);

Expand Down Expand Up @@ -249,7 +249,7 @@ You can use an array (or list) as well, and can also return a numerical value:
```java
TemplateParser parser = new TemplateParser.Builder().withFilter((new Filter("sum"){
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

Object[] numbers = super.asArray(value, context);

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/liqp/Examples.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private static void demoCustomStrongFilter() {
// first register your custom filter
TemplateParser parser = new TemplateParser.Builder().withFilter(new Filter("b") {
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {
// create a string from the value
String text = super.asString(value, context);

Expand All @@ -69,7 +69,7 @@ public Object apply(TemplateContext context, Object value, Object... params) {
private static void demoCustomRepeatFilter() {
TemplateParser parser = new TemplateParser.Builder().withFilter(new Filter("repeat") {
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

// check if an optional parameter is provided
int times = params.length == 0 ? 1 : super.asNumber(params[0]).intValue();
Expand All @@ -96,7 +96,7 @@ public Object apply(TemplateContext context, Object value, Object... params) {
private static void demoCustomSumFilter() {
TemplateParser parser = new TemplateParser.Builder().withFilter(new Filter("sum") {
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

Object[] numbers = super.asArray(value, context);

Expand Down Expand Up @@ -147,7 +147,7 @@ public static void instanceFilter() {

TemplateParser parser = new TemplateParser.Builder().withFilter(new Filter("sum") {
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

Object[] numbers = super.asArray(value, context);

Expand Down Expand Up @@ -199,7 +199,7 @@ public static void customFilter() {

TemplateParser parser = new TemplateParser.Builder().withFilter(new Filter("sum") {
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

Object[] numbers = super.asArray(value, context);
double sum = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Abs.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Abs extends Filter {
end
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

if (super.isInteger(value) || super.canBeInteger(value)) {
return Math.abs(super.asNumber(value).longValue());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Absolute_Url.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def compute_absolute_url(input)
*/

@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {
String valAsString = asString(value, context);
if (isValidAbsoluteUrl(valAsString)) {
return valAsString;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Append.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Append extends Filter {
* add one string to another
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

return super.asString(value, context) + super.asString(super.get(0, params), context);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/At_Least.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class At_Least extends Filter {

@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

if (params == null || params.length == 0) {
return value;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/At_Most.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class At_Most extends Filter {

@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

if (params == null || params.length == 0) {
return value;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Capitalize.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Capitalize extends Filter {
* capitalize words in the input sentence
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

String original = super.asString(value, context);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Ceil.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class Ceil extends Filter {

@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

if (!super.isNumber(value)) {
return value;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Compact.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class Compact extends Filter {

@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

if (!super.isArray(value)) {
return value;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Concat.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public class Concat extends Filter {

@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

super.checkParams(params, 1);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Date.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected Date(CustomDateFormatSupport<?> typeSupport) {


@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {
Locale locale = context.getParser().locale;

if (isArray(value) && asArray(value, context).length ==1) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Default.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class Default extends Filter {

@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

if (params == null || params.length == 0) {
return value;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Divided_By.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Divided_By extends Filter {
* division
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

if(value == null) {
value = 0L;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Downcase.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Downcase extends Filter {
* convert a input string to DOWNCASE
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

return super.asString(value, context).toLowerCase();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Escape.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Escape extends Filter {
* escape a string
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

String str = super.asString(value, context);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Escape_Once.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Escape_Once extends Filter {
* existing escaped entities
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

String str = super.asString(value, context);

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/liqp/filters/Filter.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public String getName() {
/**
* Applies the filter on the 'value', with the given 'context'.
*
* @param context the template context.
* @param value the string value `AAA` in: `{{ 'AAA' | f:1,2,3 }}`
* @param context the template context.
* @param params the values [1, 2, 3] in: `{{ 'AAA' | f:1,2,3 }}`
* @return the result of the filter.
*/
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

return value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/First.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class First extends Filter {
* Get the first element of the passed in array
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

Object[] array = super.asArray(value, context);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Floor.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class Floor extends Filter {

@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

if (!super.isNumber(value)) {
return value;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/liqp/filters/H.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class H extends Filter {
* Alias for: escape
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
return Filters.COMMON_FILTERS.get("escape").apply(context, value, params);
public Object apply(Object value, TemplateContext context, Object... params) {
return Filters.COMMON_FILTERS.get("escape").apply(value, context, params);
}
}
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Join.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Join extends Filter {
* Join elements of the array with certain character between them
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

if (value == null) {
return "";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Last.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Last extends Filter {
* Get the last element of the passed in array
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

Object[] array = super.asArray(value, context);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Lstrip.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class Lstrip extends Filter {

@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

if (!super.isString(value)) {
return value;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class Map extends Filter {
* map/collect on a given property
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

if (value == null) {
return "";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Minus.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Minus extends Filter {
* subtraction
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

if (!isNumber(value)) {
value = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Modulo.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Modulo extends Filter {
* modulus
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

if(value == null) {
value = 0L;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Newline_To_Br.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Newline_To_Br extends Filter {
* Add <br /> tags in front of all newlines in input string
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

return super.asString(value, context).replaceAll("[\n]", "<br />\n");
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Normalize_Whitespace.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public Normalize_Whitespace() {
}

@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {
if (value == null) {
return "";
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Plus.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Plus extends Filter {
* addition
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

if (!isNumber(value)) {
value = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Pop.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class Pop extends Filter {

@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {
if (!super.isArray(value)) {
return value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Prepend.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Prepend extends Filter {
* add one string to another
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

return super.asString(super.get(0, params), context) + super.asString(value, context);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Push.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class Push extends Filter {

@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {
if (!super.isArray(value)) {
return value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Relative_Url.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Relative_Url extends Filter {
public static final String site = "site";
public static final String baseurl = "baseurl";
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {
String valAsString = asString(value, context);

// fast exit for valid absolute urls
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Remove.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Remove extends Filter {
* remove a substring
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

String original = super.asString(value, context);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Remove_First.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class Remove_First extends Filter {
* remove the first occurrences of a substring
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

String original = super.asString(value, context);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/liqp/filters/Replace.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Replace extends Filter {
* Replace occurrences of a string with another
*/
@Override
public Object apply(TemplateContext context, Object value, Object... params) {
public Object apply(Object value, TemplateContext context, Object... params) {

String original = super.asString(value, context);

Expand Down
Loading

0 comments on commit b5aac74

Please sign in to comment.