feat(mustache): Add a trim function. Resolves
@@ -136,6 +136,7 @@ public final class MustacheUtils {
}
props.put("f_now", new TimeFormatFunction(now));
+ props.put("f_trim", new TrimFunction());
props.put("f_underscore", new UnderscoreFunction());
props.put("f_dash", new DashFunction());
props.put("f_slash", new SlashFunction());
@@ -179,6 +180,13 @@ public final class MustacheUtils {
}
}
+ public static class TrimFunction implements Function<String, String> {
+ @Override
+ public String apply(String input) {
+ return input.trim();
+ }
+ }
+
public static class UnderscoreFunction implements Function<String, String> {
@Override
public String apply(String input) {
@@ -240,7 +248,7 @@ public final class MustacheUtils {
Parser parser = Parser.builder().build();
Node document = parser.parse(input);
HtmlRenderer renderer = HtmlRenderer.builder().build();
- return renderer.render(document);
+ return renderer.render(document).trim();
}
}
