freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject incubator-freemarker git commit: Forward ported from 2.3-gae: When specifying the output_format configuration settings with String-String key-value pairs (like with Configuration.setSetting(String, String) or in a .properties file), it's now possible to
Date Tue, 20 Mar 2018 18:53:54 GMT
Repository: incubator-freemarker
Updated Branches:
  refs/heads/3 421f4747b -> 4b12b5b1c


Forward ported from 2.3-gae: When specifying the output_format configuration settings with
String-String key-value pairs (like with Configuration.setSetting(String, String) or in a
.properties file), it's now possible to specify the standard output formats by name rather
than by class name  (like output_format=HTML). (Custom formats still has to be referred by
class name, as FreeMarker can't discover what their names are, since it's not aware of the
custom classes.)


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/4b12b5b1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/4b12b5b1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/4b12b5b1

Branch: refs/heads/3
Commit: 4b12b5b1cd0129c5bf58f4126307009bb7d55ef8
Parents: 421f474
Author: ddekany <ddekany@apache.org>
Authored: Tue Mar 20 19:53:48 2018 +0100
Committer: ddekany <ddekany@apache.org>
Committed: Tue Mar 20 19:53:48 2018 +0100

----------------------------------------------------------------------
 .../core/MutableParsingAndProcessingConfigurationTest.java    | 3 +++
 .../main/java/org/apache/freemarker/core/Configuration.java   | 2 +-
 .../core/MutableParsingAndProcessingConfiguration.java        | 7 +++++--
 3 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b12b5b1/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableParsingAndProcessingConfigurationTest.java
----------------------------------------------------------------------
diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableParsingAndProcessingConfigurationTest.java
b/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableParsingAndProcessingConfigurationTest.java
index cbdcbe4..51a331f 100644
--- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableParsingAndProcessingConfigurationTest.java
+++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableParsingAndProcessingConfigurationTest.java
@@ -85,6 +85,9 @@ public class MutableParsingAndProcessingConfigurationTest {
         cfgB.setSetting(Configuration.ExtendableBuilder.OUTPUT_FORMAT_KEY, HTMLOutputFormat.class.getSimpleName());
         assertEquals(HTMLOutputFormat.INSTANCE, cfgB.getOutputFormat());
 
+        cfgB.setSetting(Configuration.ExtendableBuilder.OUTPUT_FORMAT_KEY, XMLOutputFormat.INSTANCE.getName());
+        assertEquals(XMLOutputFormat.INSTANCE, cfgB.getOutputFormat());
+        
         cfgB.unsetOutputFormat();
         assertEquals(UndefinedOutputFormat.INSTANCE, cfgB.getOutputFormat());
         assertFalse(cfgB.isOutputFormatSet());

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b12b5b1/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java b/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java
index fb113d9..5b23091 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java
@@ -132,7 +132,7 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc
     
     private static final String VERSION_PROPERTIES_PATH = "/org/apache/freemarker/core/version.properties";
 
-    private static final Map<String, OutputFormat> STANDARD_OUTPUT_FORMATS;
+    static final Map<String, OutputFormat> STANDARD_OUTPUT_FORMATS;
     static {
         STANDARD_OUTPUT_FORMATS = new HashMap<>();
         STANDARD_OUTPUT_FORMATS.put(UndefinedOutputFormat.INSTANCE.getName(), UndefinedOutputFormat.INSTANCE);

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b12b5b1/freemarker-core/src/main/java/org/apache/freemarker/core/MutableParsingAndProcessingConfiguration.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/MutableParsingAndProcessingConfiguration.java
b/freemarker-core/src/main/java/org/apache/freemarker/core/MutableParsingAndProcessingConfiguration.java
index a486547..ef174ab 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/MutableParsingAndProcessingConfiguration.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/MutableParsingAndProcessingConfiguration.java
@@ -91,8 +91,11 @@ public abstract class MutableParsingAndProcessingConfiguration<
                 if (value.equalsIgnoreCase(DEFAULT_VALUE)) {
                     unsetOutputFormat();
                 } else {
-                    setOutputFormat((OutputFormat) _ObjectBuilderSettingEvaluator.eval(
-                            value, OutputFormat.class, true, _SettingEvaluationEnvironment.getCurrent()));
+                    OutputFormat stdOF = Configuration.STANDARD_OUTPUT_FORMATS.get(value);
+                    setOutputFormat(
+                            stdOF != null ? stdOF
+                            : (OutputFormat) _ObjectBuilderSettingEvaluator.eval(
+                                    value, OutputFormat.class, true, _SettingEvaluationEnvironment.getCurrent()));
                 }
             } else if (WHITESPACE_STRIPPING_KEY.equals(name)) {
                 setWhitespaceStripping(_StringUtils.getYesNo(value));


Mime
View raw message