org.spincast.website.pebble.AppPebbleExtension Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spincast-website Show documentation
Show all versions of spincast-website Show documentation
Source code for the https://www.spincast.org website.
package org.spincast.website.pebble;
import java.util.List;
import java.util.Map;
import org.jsoup.Jsoup;
import org.spincast.core.utils.SpincastStatics;
import com.mitchellbosecke.pebble.extension.AbstractExtension;
import com.mitchellbosecke.pebble.extension.Filter;
/**
* Custom Pebble extension.
*/
public class AppPebbleExtension extends AbstractExtension {
public static final String REMOVE_HTML_TAGS_FILTER_NAME = "strip";
@Override
public Map getFilters() {
//==========================================
// Pebble filter to remove the HTML tags.
//==========================================
Filter filter = new Filter() {
@Override
public List getArgumentNames() {
return null;
}
@Override
public Object apply(Object input, Map args) {
if (input == null) {
return null;
}
String str = (String)input;
return Jsoup.parse(str).text();
}
};
return SpincastStatics.map(REMOVE_HTML_TAGS_FILTER_NAME, filter);
}
}