This is an automated email from the ASF dual-hosted git repository.
jamesyong pushed a commit to branch trunk
in repository
https://gitbox.apache.org/repos/asf/ofbiz-framework.gitThe following commit(s) were added to refs/heads/trunk by this push:
new 203fa5f Implemented: Support Freemarker square interpolation syntax (OFBIZ-12099)
203fa5f is described below
commit 203fa5f1c1bc2ae34d964936e75a74fc7d79a457
Author: James Yong <
[hidden email]>
AuthorDate: Mon Dec 21 19:46:11 2020 +0800
Implemented: Support Freemarker square interpolation syntax (OFBIZ-12099)
Use square interpolation syntax when file extension is .spi.ftl
---
.../main/java/org/apache/ofbiz/widget/model/HtmlWidget.java | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java
index 942b3c1..cde3114 100644
--- a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java
+++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java
@@ -70,7 +70,11 @@ public class HtmlWidget extends ModelScreenWidget {
private static final UtilCache<String, Template> SPECIAL_TEMPLATE_CACHE =
UtilCache.createUtilCache("widget.screen.template.ftl.general", 0, 0, false);
protected static final Configuration SPECIAL_CONFIG = FreeMarkerWorker.makeConfiguration(new ExtendedWrapper(FreeMarkerWorker.VERSION));
-
+ private static final Configuration SPECIAL_CONFIG_SQUARE_INTERPOLATION =
+ FreeMarkerWorker.makeConfiguration(new ExtendedWrapper(FreeMarkerWorker.VERSION));
+ static {
+ SPECIAL_CONFIG_SQUARE_INTERPOLATION.setInterpolationSyntax(Configuration.SQUARE_BRACKET_INTERPOLATION_SYNTAX);
+ }
// not sure if this is the best way to get FTL to use my fancy MapModel derivative, but should work at least...
public static class ExtendedWrapper extends BeansWrapper {
public ExtendedWrapper(Version version) {
@@ -176,7 +180,11 @@ public class HtmlWidget extends ModelScreenWidget {
if (location.endsWith(".fo.ftl")) { // FOP can't render correctly escaped characters
template = FreeMarkerWorker.getTemplate(location);
} else {
- template = FreeMarkerWorker.getTemplate(location, SPECIAL_TEMPLATE_CACHE, SPECIAL_CONFIG);
+ if (location.endsWith(".sqi.ftl")) {
+ template = FreeMarkerWorker.getTemplate(location, SPECIAL_TEMPLATE_CACHE, SPECIAL_CONFIG_SQUARE_INTERPOLATION);
+ } else {
+ template = FreeMarkerWorker.getTemplate(location, SPECIAL_TEMPLATE_CACHE, SPECIAL_CONFIG);
+ }
}
FreeMarkerWorker.renderTemplate(template, context, writer);