Moved Manual (documentation) related things to its own module, freemarker-manual. Because it covers all modules, not just freemarker-core, that's the logical place for it.
Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/abfcac88 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/abfcac88 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/abfcac88 Branch: refs/heads/3 Commit: abfcac8834833d44f1bc1eb8efac580587aebf56 Parents: 49df603 Author: ddekany <[email protected]> Authored: Tue May 16 19:30:27 2017 +0200 Committer: ddekany <[email protected]> Committed: Tue May 16 19:39:58 2017 +0200 ---------------------------------------------------------------------- FM3-CHANGE-LOG.txt | 232 +++++++++++++++++++ .../manualtest/AutoEscapingExample.java | 72 ------ .../ConfigureOutputFormatExamples.java | 105 --------- .../manualtest/CustomFormatsExample.java | 84 ------- .../manualtest/GettingStartedExample.java | 69 ------ .../apache/freemarker/manualtest/Product.java | 49 ---- .../TemplateConfigurationExamples.java | 191 --------------- .../UnitAwareTemplateNumberFormatFactory.java | 80 ------- .../UnitAwareTemplateNumberModel.java | 43 ---- .../manualtest/AutoEscapingExample-capture.ftlh | 21 -- .../AutoEscapingExample-capture.ftlh.out | 20 -- .../manualtest/AutoEscapingExample-convert.ftlh | 27 --- .../AutoEscapingExample-convert.ftlh.out | 25 -- .../manualtest/AutoEscapingExample-convert2.ftl | 25 -- .../AutoEscapingExample-convert2.ftl.out | 21 -- .../manualtest/AutoEscapingExample-infoBox.ftlh | 26 --- .../AutoEscapingExample-infoBox.ftlh.out | 25 -- .../manualtest/AutoEscapingExample-markup.ftlh | 28 --- .../AutoEscapingExample-markup.ftlh.out | 26 --- .../AutoEscapingExample-stringConcat.ftlh | 19 -- .../AutoEscapingExample-stringConcat.ftlh.out | 19 -- .../AutoEscapingExample-stringLiteral.ftlh | 21 -- .../AutoEscapingExample-stringLiteral.ftlh.out | 20 -- .../AutoEscapingExample-stringLiteral2.ftlh | 25 -- .../AutoEscapingExample-stringLiteral2.ftlh.out | 21 -- .../ConfigureOutputFormatExamples1.properties | 21 -- .../ConfigureOutputFormatExamples2.properties | 31 --- .../manualtest/CustomFormatsExample-alias1.ftlh | 22 -- .../CustomFormatsExample-alias1.ftlh.out | 22 -- .../manualtest/CustomFormatsExample-alias2.ftlh | 19 -- .../CustomFormatsExample-alias2.ftlh.out | 19 -- .../CustomFormatsExample-modelAware.ftlh | 20 -- .../CustomFormatsExample-modelAware.ftlh.out | 20 -- .../TemplateConfigurationExamples1.properties | 25 -- .../TemplateConfigurationExamples2.properties | 32 --- .../TemplateConfigurationExamples3.properties | 47 ---- .../org/apache/freemarker/manualtest/test.ftlh | 28 --- .../src/manual/en_US/FM3-CHANGE-LOG.txt | 232 ------------------- freemarker-core/src/manual/en_US/book.xml | 82 ------- .../manual/en_US/docgen-help/editors-readme.txt | 130 ----------- .../en_US/docgen-misc/copyrightComment.txt | 16 -- .../en_US/docgen-misc/googleAnalytics.html | 14 -- .../figures/model2sketch_with_alpha.png | Bin 61463 -> 0 bytes .../figures/odg-convert-howto.txt | 43 ---- .../en_US/docgen-originals/figures/overview.odg | Bin 11939 -> 0 bytes .../figures/tree_with_alpha.png | Bin 10304 -> 0 bytes freemarker-core/src/manual/en_US/docgen.cjson | 132 ----------- freemarker-core/src/manual/en_US/favicon.png | Bin 1291 -> 0 bytes .../src/manual/en_US/figures/model2sketch.png | Bin 21425 -> 0 bytes .../src/manual/en_US/figures/overview.png | Bin 11837 -> 0 bytes .../src/manual/en_US/figures/tree.png | Bin 4699 -> 0 bytes freemarker-core/src/manual/en_US/logo.png | Bin 10134 -> 0 bytes freemarker-core/src/manual/zh_CN/book.xml | 82 ------- .../src/manual/zh_CN/docgen-help/README | 2 - .../zh_CN/docgen-misc/googleAnalytics.html | 14 -- .../zh_CN/docgen-originals/figures/README | 2 - freemarker-core/src/manual/zh_CN/docgen.cjson | 130 ----------- freemarker-core/src/manual/zh_CN/favicon.png | Bin 1291 -> 0 bytes .../src/manual/zh_CN/figures/model2sketch.png | Bin 21425 -> 0 bytes .../src/manual/zh_CN/figures/overview.png | Bin 11837 -> 0 bytes .../src/manual/zh_CN/figures/tree.png | Bin 4699 -> 0 bytes freemarker-core/src/manual/zh_CN/logo.png | Bin 10134 -> 0 bytes freemarker-manual/build.gradle | 26 +++ .../src/main/docgen/en_US/book.xml | 82 +++++++ .../docgen/en_US/docgen-help/editors-readme.txt | 130 +++++++++++ .../en_US/docgen-misc/copyrightComment.txt | 16 ++ .../en_US/docgen-misc/googleAnalytics.html | 14 ++ .../figures/model2sketch_with_alpha.png | Bin 0 -> 61463 bytes .../figures/odg-convert-howto.txt | 43 ++++ .../en_US/docgen-originals/figures/overview.odg | Bin 0 -> 11939 bytes .../figures/tree_with_alpha.png | Bin 0 -> 10304 bytes .../src/main/docgen/en_US/docgen.cjson | 132 +++++++++++ .../src/main/docgen/en_US/favicon.png | Bin 0 -> 1291 bytes .../main/docgen/en_US/figures/model2sketch.png | Bin 0 -> 21425 bytes .../src/main/docgen/en_US/figures/overview.png | Bin 0 -> 11837 bytes .../src/main/docgen/en_US/figures/tree.png | Bin 0 -> 4699 bytes .../src/main/docgen/en_US/logo.png | Bin 0 -> 10134 bytes .../manual/examples/AutoEscapingExample.java | 72 ++++++ .../BaseNTemplateNumberFormatFactory.java | 128 ++++++++++ .../examples/ConfigureOutputFormatExamples.java | 105 +++++++++ .../manual/examples/CustomFormatsExample.java | 83 +++++++ .../manual/examples/GettingStartedExample.java | 69 ++++++ .../freemarker/manual/examples/Product.java | 49 ++++ .../examples/TemplateConfigurationExamples.java | 191 +++++++++++++++ .../UnitAwareTemplateNumberFormatFactory.java | 80 +++++++ .../examples/UnitAwareTemplateNumberModel.java | 43 ++++ .../examples/AutoEscapingExample-capture.ftlh | 21 ++ .../AutoEscapingExample-capture.ftlh.out | 20 ++ .../examples/AutoEscapingExample-convert.ftlh | 27 +++ .../AutoEscapingExample-convert.ftlh.out | 25 ++ .../examples/AutoEscapingExample-convert2.ftl | 25 ++ .../AutoEscapingExample-convert2.ftl.out | 21 ++ .../examples/AutoEscapingExample-infoBox.ftlh | 26 +++ .../AutoEscapingExample-infoBox.ftlh.out | 25 ++ .../examples/AutoEscapingExample-markup.ftlh | 28 +++ .../AutoEscapingExample-markup.ftlh.out | 26 +++ .../AutoEscapingExample-stringConcat.ftlh | 19 ++ .../AutoEscapingExample-stringConcat.ftlh.out | 19 ++ .../AutoEscapingExample-stringLiteral.ftlh | 21 ++ .../AutoEscapingExample-stringLiteral.ftlh.out | 20 ++ .../AutoEscapingExample-stringLiteral2.ftlh | 25 ++ .../AutoEscapingExample-stringLiteral2.ftlh.out | 21 ++ .../ConfigureOutputFormatExamples1.properties | 21 ++ .../ConfigureOutputFormatExamples2.properties | 31 +++ .../examples/CustomFormatsExample-alias1.ftlh | 22 ++ .../CustomFormatsExample-alias1.ftlh.out | 22 ++ .../examples/CustomFormatsExample-alias2.ftlh | 19 ++ .../CustomFormatsExample-alias2.ftlh.out | 19 ++ .../CustomFormatsExample-modelAware.ftlh | 20 ++ .../CustomFormatsExample-modelAware.ftlh.out | 20 ++ .../TemplateConfigurationExamples1.properties | 25 ++ .../TemplateConfigurationExamples2.properties | 32 +++ .../TemplateConfigurationExamples3.properties | 47 ++++ .../apache/freemarker/manual/examples/test.ftlh | 28 +++ settings.gradle | 1 + 115 files changed, 2171 insertions(+), 2247 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/FM3-CHANGE-LOG.txt ---------------------------------------------------------------------- diff --git a/FM3-CHANGE-LOG.txt b/FM3-CHANGE-LOG.txt new file mode 100644 index 0000000..64a2a38 --- /dev/null +++ b/FM3-CHANGE-LOG.txt @@ -0,0 +1,232 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +Because the Manual won't be updated for a good while, I will lead +the FreeMarer 3 changelog here: + +- Increased version number to 3.0.0 (nightly aka. SNAPSHOT) +- Removed legacy extensions: rhyno, jython, xml (not to be confused with dom), jdom, ant. +- Removed JSP 2.0 support (2.1 and Servlet 2.5 is the minimum for now, but maybe it will be 2.2 and Servlet 3.0 later). +- Removed freemarker.ext.log, our log abstraction layer from the old times when there was no clear winner on this field. + Added org.slf4j:slf4j-api as required dependency instead. +- Removed all classes with "main" methods that were part of freemarker.jar. Such tools should be separate artifacts, + not part of the library, and they are often classified as CWE-489 "Leftover Debug Code". The removed classes are: + freemarker.core.CommandLine, freemarker.ext.dom.Transform, freemarker.template.utility.ToCanonical +- Removed classic_compatible (classicCompatible) setting, which was used to emulate some of the FreeMarker 1.x behavior +- Removed utility TemplateModel-s that can very easily mean a security problem: freemarker.template.utility.Execute and + freemarker.template.utility.ObjectConstructor +- Removed TemplateClassResolver.SAFER_RESOLVER, because the classes it has blocked were removed from FreeMarker, so it's + the same as UNRESTRICTED_RESOLVER +- Removed the strict_syntax setting, and so also the support for FTL tags without #. This was a FreeMarker 1.x + compatibility option. +- Removed deprecated FMParser contstructors. +- Minimum Java version increased to 7, but without try-with-resource as that's unavailable before Android 4.4 KitKat. +- Totally redesigned TemplateLoader interface. The FM2 TemplateLoader can't be adapted (wrapped) to it, but usually + it's fairly trivial to "rearrange" an old custom TemplateLoader for the new interface. The new TemplateLoader comes + with several advantages, such as: + - It can work more efficiently with sophisticated storage mechanisms like a database, as it's now possible to pack + together the existence check, the last modification change check, and reading operations into less storage level + operations (like you can do all of them with a single SQL statement). + - The new TemplateLoader allows returning the template content either as an InputStream or as a Reader. Almost all + TemplateLoader-s should return InputStream, and FreeMarker takes care of charset issues transparently (as a result, + TemplateLoader-s don't have to support re-reading a template anymore, as we solve charset detection misses in + memory). TemplateLoader-s that are inherently backed by text (String-s), such as templates stored in a varchar or + CLOB column, should return a Reader. Note that templates created from a Reader will have template.getEncoding() + null (logically, as no charset was involved), which was impossible in FreeMarker 2. + - The change detection of the template doesn't have to rely on a millisecond resolution timestamp anymore; you can + use what's most appropriate for the storage mechanism, such as a cryptographic hash or a revision number. + - Template lookups (where you try multiple names until you find the best template) can now be transactional and/or + atomic if the backing storage mechanism supports that, by utilizing the TemplateLoaderSession interface. + - TemplateLoader can now return template-level settings like the output format (MIME type basically) of the loaded + template, in case the backing storage stores such extra information. This mechanism can be used together with + the TemplateConfiguration mechanism (already familiar from FreeMarker 2), and overrides the individual settings + coming from there. +- Template constructors won't close the Reader passed in as agrument anymore (because a Reader should be closed + by who has created it). This avoids some surprises from the past, such as the unablility to reset a Reader to a mark + after parsing. If you call those constructors, be sure that you close the Reader yourself. (Obviously, it doesn't + mater for StringReader-s.) +- Renamed top level java package from freemarker to org.apache.freemarker +- Reorganized package structure. We will have a freemarker-core and a freemarker-servlet module later, so + we got org.apache.freemarker.core (has nothing to do with the old freemarker.core) and + org.apache.freemarker.servlet (this replaced freemarker.ext.servlet and freemarker.ext.jsp). + Directly inside org.apache.freemarker.core we have most of the classes that were in + freemarker.template and freemarker.core, however, model related classes (and object wrappers) + were moved to org.apache.freemarker.core.model, and template loading and caching related classes + to org.apache.freemarker.core.templateresolver (because later we will have a class called + TemplateResolver, which is the central class of loading and caching and template name rules). + OutputFormat realted classes were moved to org.apache.freemarker.core.outputformat. + ValueFormat related classes were moved to org.apache.freemarker.core.valueformat. + ArithmeticEngine related classes were moved to org.apache.freemarker.core.arithmetic. + freemarker.ext.dom was moved into org.apache.freemarker.dom. +- Moved the all the static final ObjectWrapper-s to the new _StaticObjectWrappers class, and made them + write protected (non-configurable). Also now they come from the pool that ObjectWrapper builders use. +- WrappingTemplateModel.objectWrapper is now final, and its statically stored default value can't be set anymore. +- Removed SimpleObjectWrapper deprecated paramerless constructor +- Removed ResourceBundleLocalizedString and LocalizedString: Hardly anybody has discovered these, and they had no + JUnit coverage. +- Added early draft of TemplateResolver, renamed TemplateCache to DefaultTemplateResolver. TemplateResolver is not + yet directly used in Configuration. This was only added in a hurry, so that it's visible why the + o.a.f.core.templateresolver subpackage name makes sense. +- Marked most static utility classes as internal, and renamed them to start with "_" (for example StringUtils was + renamed to _StringUtil, thus people won't accidentally use it when they wanted to autocomplete to Apache Commons + StringUtil). Created published static utility class, o.a.f.core.util.FTLUtil, which contains some methods moved + over from the now internal utility classes. +- Deleted o.a.f.core.util.DOMNodeModel (it has noting to do with the standard XML support, o.a.f.core.model.dom) +- All CacheStorage-s must be thread safe from now on (removed ConcurrentCacheStorage marker interface) +- Removed support for incompatibleImprovements before 3.0.0. So currently 3.0.0 is the only support value. +- Changed the default of logTemplateExceptions to false. +- Removed `String Configurable.getSetting(String)` and `Properties getSettings()`. It has never worked well, + and is impossible to implement properly. +- Even for setting values that are class names without following `()` or other argument list, the INSTANCE field and + the builder class will be searched now, and used instead of the constructor of the class. Earlier they weren't for + backward compatibility. +- Removed several deprecated methods and constants. Some notes: + - strict_bean_models configuration setting was removed, as it should be set on the BeansWrapper itself + - .template_name now means the same as .current_template_name (it doesn't emulate 2.3 glitches anymore) + - Removed the deprecated BeansWrapper.nullModel setting. So null is always wrapped to null now. + - Removed the overridable BeansWrapper.finetuneMethodAppearance method, which was deprecated by the + finetuneMethodAppearance setting (BeansWrapper.setFinetuneMethodAppearance). + - Removed NodeModel static utility classes dealing with parsing XML to DOM. How it's best to do that is environment + and application dependent, and it has security implications. Since XML loading/parsing is not the topic of the + project, these were removed. Static methods that simplify an already loaded DOM have remained, because that's + FreeMarker-specific functionality. + - Removed parameterless DefaultObjectWrapper and BeansWrapper constructors. Now specifying the + incomplatibleImprovement version is required. + - Removed the static default Configuration instance. (It's not possible to create a template with null Configuration + constructor argument anymore.) + - When specifying the templateUpdateDelay configuration setting with a String (with Properties), the time unit is + required, unless the value is 0. +- setSetting (and the like) doesn't throw ParseException (the same exception used when parsing templates) anymore, + but ConfigurationException. Also, on the places where ParseException was used for other than template parsing, + o.a.f.core.util.GenericParseException is used now instead, which doesn't have the template parsing related fields + that we can't fill. +- Removed DefaultObjectWrapper settings that only exist so that you can set backward compatible behavior instead of + the recommended value: useAdaptersForContainers, forceLegacyNonListCollections, iterableSupport, simpleMapWrapper +- Removed BeansWrapper, which was the superclass of DefaultObjectWrapper, but wasn't recommended to be used as is. + Removed many BeansWrapper-related classes that DefaultObjectWrapper doesn't use. This includes ModelCache and + related classes, because DefaultObjectWrapper has only used the cache for "generic" classes (because that's where it + has fallen back to BeansWrapper.wrap), which is inconsistent and doesn't worth the caching overhead and complexity. +- Java methods (when using DefaultObjectWrapper) won't be accessible as sequences anyore. That is, earlier, instead of + obj.m(1), you could write obj.m[1]. This strange feature has led to some tricky cases, while almost nobody has + utilized it. +- SimpleObjectWrapper was renamed to RestrictedObjectWrapper, also the "simple" setting value was rename to + "restricted". +- Removed the global static final ObjectWrapper-s. It had a "few" consequences: + - Standard TemplateModel implementations that can have an ObjectWrapper contrucor parameter don't allow null there anymore. + Also, any constructor overloads where you cold omit the ObjectWrapper were removed (these were deprecated in FM2 too). + In FM2, such overloads has used the global static default DefaltObjectWrapper, but that was removed. + - If the ObjectWrapper is not a DefaultObjectWrapper (or a subclass of it), `className?new(args)` will only accept 0 arguments. + (Earlier we have fallen back to using the global static default DefaultObjectWrapper instance to handle argument unwrapping + and overloaded constructors.) Note that ?new is only used to instantiate TemplateModel-s, typically, template language + functions/directives implemented in Java, and so they hardly ever has an argument. + - FreemarkerServlet now requires that the ObjectWrapper it uses implements ObjectWrapperAndUnwrapper. (Thus, the return type + of FreemarerServlet.createDefaultObjectWrapper() has changed to ObjectWrapperAndUnwrapper.) The unwrapping functionality is + required when calling JSP custom tags/functions, and in FreeMarker 2 this was worked around with using the + global static default DefaultObjectWrapper when the ObjectWrapper wasn't an ObjectWrapperAndUnwrapper. +- Removed some long deprecated template language directives: + - <#call ...> (deprecated by <@... />) + - <#comment>...</#comment> (deprecated by <#-- ... -->) + - <#transform ...>...</#transform> (deprecated by <@...>...</@...>) + - <#foreach x in xs>...</#foreach> (deprecated by <#list xs as x>...</#list>) +- If for an indexed JavaBean property there's both an indexed read method (like `Foo getFoo(int index)`) and a normal read method + (like Foo[] getFoo()), we prefer the normal read method, and so the result will be a clean FTL sequence (not a multi-type value + with sequence+method type). If there's only an indexed read method, then we don't expose the property anymore, but the indexed + read method can still be called as an usual method (as `myObj.getFoo(index)`). These changes were made because building on the + indexed read method we can't create a proper sequence (which the value of the property should be), since sequences are required + to support returning their size. (In FreeMarker 2 such sequences has thrown exception on calling size(), which caused more + problems and confusion than it solved.) +- When looking for a builder class in builder expressions used in setting values like `com.example.Foo()`, now we first + look for com.example.Foo.Builder, and only then com.example.FooBuilder. +- Removed DefaultObjectWrapper.methodsShadowItems setting, in effect defaulting it to true. This has decided if the generic + get method (`get(String)`) had priority over methods of similar name. The generic get method is only recognized from its + name and parameter type, so it's a quite consfusing feature, and might will be removed alltogether. +- DefaultObjectWrapper is now immutable (has no setter methods), and can only be constructed with DefaultObjectWrapper.Builder +- Configuration.getTemplate has no "parse" parameter anymore. Similarly #include has no "parse" parameter anymore. Whether a + template is parsed can be specified via Configuration.templateConfigurations, for example based on the file extension. Thus, + a certain template is either always parsed or never parsed, and whoever gets or include it need not know about that. + Also added a new setting, "templateLanguage", which decides this; the two available values are + TemplateLanguage.FTL and TemplateLanguage.STATIC_TEXT. +- Configuration.getTemplate has no "encoding" parameter anymore. Similarly #include has no "encoding" parameter either. The charset + of templates can be specified via Configuration.defaultEncoding and Configuration.templateConfigurations (for example based on the + directory it is in), or wirh the #ftl directive inside the template. Thus, a given template always has the same charset, no mater how + it's accessed. +- #include-d/#import-ed templates don't inheirit the charset (encoding) of the #include-ing/#import-ing template. (Because, + again, the charset of a template file is independent of how you access it.) +- Removed Configuration.setEncoding(java.util.Locale, String) and the related other methods. Because of the new logic of template + encodings, the locale to encoding mapping doesn't make much sense anymore. +- Require customLookupCondition-s to be Serializable. +- Various refactorings of Configurable and its subclasses. This is part of the preparation for making such classes immutable, and offer + builders to create them. + - Removed CustomAttribute class. Custom attribute keys can be anything at the moment (this will be certainly restricted later) + - As customAttributes won't be modifiable after Builder.build(), they can't be used for on-demand created data structures anymore (such as + Template-scoped caches) anymore. To fulfill that role, the CustomStateKey class and the CustomStateScope interface was introduced, which + is somewhat similar to the now removed CustomAttribute. CustomStateScope contains one method, Object getCustomState(CustomStateKey), which + may calls CustomStateKey.create() to lazily create the state object for the key. Configuration, Template and Environment implements + CustomStateScope. + - Added getter/setter to access custom attributes as a Map. (This is to make it less an exceptional setting.) + - Environment.setCustomState(Object, Object) and getCustomState(Object) was replaced with CustomStateScope.getCustomState(CustomStateKey). + - Added ProcessingConfiguration interface for the read-only access of template processing settings. This is similar to the + already existing (in FM2) ParserConfiguration interface. + - Renamed Configurable to MutableProcessingAndParserConfiguration. Made it abstract too. + - Renamed Configuration.defaultEncoding to sourceEncoding, also added sourceEncoding to ParserConfiguration, and renamed + TemplateConfiguration.encoding and Template.encoding to sourceEncoding. (Before this, defaultEncoding was exclusive + to Configuration, but now it's like any other ParserConfiguration setting that can be overidden on the 3 levels.) + - Made TemplateConfiguration immutable, added a TemplateConfiguration.Builder. + - Made Template immutable (via public API-s). Template-specific settings now can only come from the TemplateConfiguration associated + to the template, or from the #ftl header for some settings (most notably for custom attributes). + - Renamed ParserConfiguration to ParsingConfiguration, so that the name is more consistent with the new ProcessingConfiguration. +- Settings that have contained a charset name (sourceEncoding, outputEncoding, URLEscapingCharset) are now of type Charset, + not String. For string based configuration sources (such as .properties files) this means that: + - Unrecognized charset names are now errors + - For recognized names the charset name will be normalized (like "latin1" becomes to "ISO-8859-1"). + - In "object builder expressions" Charset values can now be constructed like `Charset("ISO-8859-5")`. + Note that as the type of the settings have changed, now you can't just write something like + `TemplateConfiguration(sourceEncoding = "UTF-8")`, but `TemplateConfiguration(sourceEncoding = Charset("UTF-8"))`. +- Removed Template.templateLanguageVersion, as we solely rely on incompatibleImprovements instead. +- Template.sourceEncoding was renamed to Template.actualSourceEncoding, to emphasize that it's not the template-layer + equivalent of the sourceEncoding ParserConfiguration setting. This is in line with Template.actualTagSyntax and the + other "actual" properties. (Just as in FM2, Template.getParserConfiguration() still can be used get the + sourceEncoding used during parsing.) +- Made TemplateModel classes used by the parser for literals Serializable. (Without this attribute values set in the #ftl + header wouldn't be always Serializable, which in turn will sabotage making Template-s Serializable in the future.) +- Removed hasCustomFormats() from configuration related API-s (we don't need it anymore) +- Template.name (getName()) was renamed to Template.lookupName (getLookupName()), and Template.sourceName (Template.getSourceName()) + doesn't fall back to the lookup name anymore when it's null (however, Template.getSourceOrLookupName() was added for that). There's + no Template.name anymore, because since sourceName was introduced, and hence the concept of template name was split into the + lookup and the source name, its meaning wasn't clean (but it meant the lookup name). TemplateException and ParseException + now also have the same properites: getTemplateSourceName(), getTemplateLookupName(), and even getSourceOrLookupName(). + Location information in error messages show getTemplateSourceOrLookupName(). +- Configuration.setSharedVaribles (not the typo in it) was renamed to setSharedVariables +- Configuration is now immutable. Instead, you should use Configuration.Builder to set up the setting values, then create + the Configuration with the builder's build() method. Further notes: + - Most of the mutator methods (like setters) were moved from Configuration to Configuration.Builder. However, + setClassForTemplateLoader, setDirectoryForTemplateLoading and the like were removed, instead there's just + setTemplateLoader. So for example. instead of setClassForTemplateLoader(Foo.class, "templates") now you have + to write setTemplateLoader(new ClassTemplateLoader(Foo.class, "templates")). While it's a bit longer, it shows + more clearly what's happening, and always supports all TemplateLoader constructor overloads. + - It's now possible to change the Configuration setting defaults by using a custom Configuration.ExtendableBuilder + subclass instead of Configuration.Builder (which is also an ExtendableBuilder subclass). FreemarkerServlet has + switched to this approach, using its own builder subclass to provide defaults that makes the sense in that particular + application. Its API-s which were used for customizing FreemarkerServlet has bean changed accordingly. +- Modularized the project. Now we have these published jar-s: + - org.apache.freemarker:freemarker-core + - org.apache.freemarker:freemarker-servlet + - [TODO] org.apache.freemarker:freemarker-dom + There are several other internal modules related to testing; these aren't published. +- Migrated buiding from Ant to Gradle. [TODO: This is only partially done; jar building, testing and javadoc works.] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/AutoEscapingExample.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/AutoEscapingExample.java b/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/AutoEscapingExample.java deleted file mode 100644 index 036bace..0000000 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/AutoEscapingExample.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.freemarker.manualtest; - -import org.apache.freemarker.core.Configuration; -import org.apache.freemarker.test.TemplateTest; -import org.apache.freemarker.test.TestConfigurationBuilder; -import org.junit.Test; - -public class AutoEscapingExample extends TemplateTest { - - @Test - public void testInfoBox() throws Exception { - assertOutputForNamed("AutoEscapingExample-infoBox.ftlh"); - } - - @Test - public void testCapture() throws Exception { - assertOutputForNamed("AutoEscapingExample-capture.ftlh"); - } - - @Test - public void testMarkup() throws Exception { - assertOutputForNamed("AutoEscapingExample-markup.ftlh"); - } - - @Test - public void testConvert() throws Exception { - assertOutputForNamed("AutoEscapingExample-convert.ftlh"); - } - - @Test - public void testConvert2() throws Exception { - assertOutputForNamed("AutoEscapingExample-convert2.ftl"); - } - - @Test - public void testStringLiteral() throws Exception { - assertOutputForNamed("AutoEscapingExample-stringLiteral.ftlh"); - } - - @Test - public void testStringLiteral2() throws Exception { - assertOutputForNamed("AutoEscapingExample-stringLiteral2.ftlh"); - } - - @Test - public void testStringConcat() throws Exception { - assertOutputForNamed("AutoEscapingExample-stringConcat.ftlh"); - } - - @Override - protected Configuration createDefaultConfiguration() throws Exception { - return new TestConfigurationBuilder(AutoEscapingExample.class).build(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/ConfigureOutputFormatExamples.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/ConfigureOutputFormatExamples.java b/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/ConfigureOutputFormatExamples.java deleted file mode 100644 index 40c1297..0000000 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/ConfigureOutputFormatExamples.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.freemarker.manualtest; - -import static org.junit.Assert.*; - -import java.io.IOException; - -import org.apache.freemarker.core.TemplateConfiguration; -import org.apache.freemarker.core.outputformat.impl.HTMLOutputFormat; -import org.apache.freemarker.core.outputformat.impl.RTFOutputFormat; -import org.apache.freemarker.core.outputformat.impl.XMLOutputFormat; -import org.apache.freemarker.core.templateresolver.ConditionalTemplateConfigurationFactory; -import org.apache.freemarker.core.templateresolver.FileExtensionMatcher; -import org.apache.freemarker.core.templateresolver.FirstMatchTemplateConfigurationFactory; -import org.apache.freemarker.core.templateresolver.OrMatcher; -import org.apache.freemarker.core.templateresolver.PathGlobMatcher; -import org.apache.freemarker.test.TemplateTest; -import org.apache.freemarker.test.TestConfigurationBuilder; -import org.junit.Test; - -public class ConfigureOutputFormatExamples extends TemplateTest { - - @Test - public void test() throws Exception { - addTemplate("mail/t.ftl", ""); - addTemplate("t.html", ""); - addTemplate("t.htm", ""); - addTemplate("t.xml", ""); - addTemplate("t.rtf", ""); - - example2(true); - example2(false); - example3(true); - example3(false); - } - - private void example2(boolean javaCfg) throws IOException { - setConfiguration( - javaCfg - ? new TestConfigurationBuilder() - .templateConfigurations( - new ConditionalTemplateConfigurationFactory( - new PathGlobMatcher("mail/**"), - new TemplateConfiguration.Builder() - .outputFormat(HTMLOutputFormat.INSTANCE) - .build())) - .build() - : new TestConfigurationBuilder() - .settings(loadPropertiesFile("ConfigureOutputFormatExamples1.properties")) - .build()); - assertEquals(HTMLOutputFormat.INSTANCE, getConfiguration().getTemplate("mail/t.ftl").getOutputFormat()); - } - - private void example3(boolean javaCfg) throws IOException { - setConfiguration( - javaCfg - ? new TestConfigurationBuilder() - .templateConfigurations( - new FirstMatchTemplateConfigurationFactory( - new ConditionalTemplateConfigurationFactory( - new FileExtensionMatcher("xml"), - new TemplateConfiguration.Builder() - .outputFormat(XMLOutputFormat.INSTANCE) - .build()), - new ConditionalTemplateConfigurationFactory( - new OrMatcher( - new FileExtensionMatcher("html"), - new FileExtensionMatcher("htm")), - new TemplateConfiguration.Builder() - .outputFormat(HTMLOutputFormat.INSTANCE) - .build()), - new ConditionalTemplateConfigurationFactory( - new FileExtensionMatcher("rtf"), - new TemplateConfiguration.Builder() - .outputFormat(RTFOutputFormat.INSTANCE) - .build())) - .allowNoMatch(true)) - .build() - : new TestConfigurationBuilder() - .settings(loadPropertiesFile("ConfigureOutputFormatExamples2.properties")) - .build()); - assertEquals(HTMLOutputFormat.INSTANCE, getConfiguration().getTemplate("t.html").getOutputFormat()); - assertEquals(HTMLOutputFormat.INSTANCE, getConfiguration().getTemplate("t.htm").getOutputFormat()); - assertEquals(XMLOutputFormat.INSTANCE, getConfiguration().getTemplate("t.xml").getOutputFormat()); - assertEquals(RTFOutputFormat.INSTANCE, getConfiguration().getTemplate("t.rtf").getOutputFormat()); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/CustomFormatsExample.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/CustomFormatsExample.java b/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/CustomFormatsExample.java deleted file mode 100644 index f38bb14..0000000 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/CustomFormatsExample.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.freemarker.manualtest; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.Date; - -import org.apache.freemarker.core.TemplateException; -import org.apache.freemarker.core.userpkg.BaseNTemplateNumberFormatFactory; -import org.apache.freemarker.core.valueformat.TemplateDateFormatFactory; -import org.apache.freemarker.core.valueformat.TemplateNumberFormatFactory; -import org.apache.freemarker.core.valueformat.impl.AliasTemplateDateFormatFactory; -import org.apache.freemarker.core.valueformat.impl.AliasTemplateNumberFormatFactory; -import org.apache.freemarker.test.TemplateTest; -import org.apache.freemarker.test.TestConfigurationBuilder; -import org.junit.Test; - -import com.google.common.collect.ImmutableMap; - -@SuppressWarnings("boxing") -public class CustomFormatsExample extends TemplateTest { - - @Test - public void aliases1() throws IOException, TemplateException { - setConfiguration(new TestConfigurationBuilder(this.getClass()) - .customNumberFormats(ImmutableMap.<String, TemplateNumberFormatFactory>of( - "price", new AliasTemplateNumberFormatFactory(",000.00"), - "weight", new AliasTemplateNumberFormatFactory("0.##;; roundingMode=halfUp"))) - .customDateFormats(ImmutableMap.<String, TemplateDateFormatFactory>of( - "fileDate", new AliasTemplateDateFormatFactory("dd/MMM/yy hh:mm a"), - "logEventTime", new AliasTemplateDateFormatFactory("iso ms u") - )) - .build()); - - addToDataModel("p", 10000); - addToDataModel("w", new BigDecimal("10.305")); - addToDataModel("fd", new Date(1450904944213L)); - addToDataModel("let", new Date(1450904944213L)); - - assertOutputForNamed("CustomFormatsExample-alias1.ftlh"); - } - - @Test - public void aliases2() throws IOException, TemplateException { - setConfiguration(new TestConfigurationBuilder(this.getClass()) - .customNumberFormats(ImmutableMap.of( - "base", BaseNTemplateNumberFormatFactory.INSTANCE, - "oct", new AliasTemplateNumberFormatFactory("@base 8"))) - .build()); - - assertOutputForNamed("CustomFormatsExample-alias2.ftlh"); - } - - @Test - public void modelAware() throws IOException, TemplateException { - setConfiguration(new TestConfigurationBuilder(this.getClass()) - .customNumberFormats(ImmutableMap.<String, TemplateNumberFormatFactory>of( - "ua", UnitAwareTemplateNumberFormatFactory.INSTANCE)) - .numberFormat("@ua 0.####;; roundingMode=halfUp") - .build()); - - addToDataModel("weight", new UnitAwareTemplateNumberModel(1.5, "kg")); - - assertOutputForNamed("CustomFormatsExample-modelAware.ftlh"); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/GettingStartedExample.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/GettingStartedExample.java b/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/GettingStartedExample.java deleted file mode 100644 index a676bc4..0000000 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/GettingStartedExample.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.freemarker.manualtest; - -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Map; - -import org.apache.freemarker.core.Configuration; -import org.apache.freemarker.core.Template; -import org.apache.freemarker.core.TemplateExceptionHandler; -import org.apache.freemarker.core.templateresolver.impl.ClassTemplateLoader; -import org.junit.Test; - -public class GettingStartedExample { - - @Test - public void main() throws Exception { - /* ------------------------------------------------------------------------ */ - /* You should do this ONLY ONCE in the whole application life-cycle: */ - - /* Create the configuration singleton (using builder pattern) */ - Configuration cfg = new Configuration.Builder(Configuration.VERSION_3_0_0) - .templateLoader(new ClassTemplateLoader(GettingStartedExample.class, "")) - .sourceEncoding(StandardCharsets.UTF_8) - .templateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER) - .logTemplateExceptions(false) - .build(); - - /* ------------------------------------------------------------------------ */ - /* You usually do these for MULTIPLE TIMES in the application life-cycle: */ - - /* Create a data-model */ - Map<String, Object> root = new HashMap(); - root.put("user", "Big Joe"); - Product latest = new Product(); - latest.setUrl("products/greenmouse.html"); - latest.setName("green mouse"); - root.put("latestProduct", latest); - - /* Get the template (uses cache internally) */ - Template temp = cfg.getTemplate("test.ftlh"); - - /* Merge data-model with template */ - Writer out = new OutputStreamWriter(System.out); - temp.process(root, out); - // Note: Depending on what `out` is, you may need to call `out.close()`. - // This is usually the case for file output, but not for servlet output. - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/Product.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/Product.java b/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/Product.java deleted file mode 100644 index fcb34e8..0000000 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/Product.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.freemarker.manualtest; - -/** - * Product bean; note that it must be a public class! - */ -public class Product { - - private String url; - private String name; - - // As per the JavaBeans spec., this defines the "url" bean property - // It must be public! - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - // As per the JavaBean spec., this defines the "name" bean property - // It must be public! - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/TemplateConfigurationExamples.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/TemplateConfigurationExamples.java b/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/TemplateConfigurationExamples.java deleted file mode 100644 index 8c515bd..0000000 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/TemplateConfigurationExamples.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.freemarker.manualtest; - -import static org.junit.Assert.*; - -import java.nio.charset.StandardCharsets; -import java.util.Date; - -import org.apache.freemarker.core.Configuration; -import org.apache.freemarker.core.Template; -import org.apache.freemarker.core.TemplateConfiguration; -import org.apache.freemarker.core.outputformat.impl.HTMLOutputFormat; -import org.apache.freemarker.core.outputformat.impl.PlainTextOutputFormat; -import org.apache.freemarker.core.outputformat.impl.UndefinedOutputFormat; -import org.apache.freemarker.core.outputformat.impl.XMLOutputFormat; -import org.apache.freemarker.core.templateresolver.ConditionalTemplateConfigurationFactory; -import org.apache.freemarker.core.templateresolver.FileExtensionMatcher; -import org.apache.freemarker.core.templateresolver.FileNameGlobMatcher; -import org.apache.freemarker.core.templateresolver.FirstMatchTemplateConfigurationFactory; -import org.apache.freemarker.core.templateresolver.MergingTemplateConfigurationFactory; -import org.apache.freemarker.core.templateresolver.OrMatcher; -import org.apache.freemarker.core.templateresolver.PathGlobMatcher; -import org.apache.freemarker.core.util._DateUtil; -import org.apache.freemarker.test.TemplateTest; -import org.apache.freemarker.test.TestConfigurationBuilder; -import org.junit.Test; - -public class TemplateConfigurationExamples extends TemplateTest { - - @Test - public void example1JavaCfg() throws Exception { - example1(true); - } - - @Test - public void example1PropertiesCfg() throws Exception { - example1(false); - } - - private void example1(boolean javaCfg) throws Exception { - TestConfigurationBuilder cfgB = new TestConfigurationBuilder(this.getClass()); - if (javaCfg) { - cfgB.setTemplateConfigurations(new ConditionalTemplateConfigurationFactory( - new FileExtensionMatcher("xml"), - new TemplateConfiguration.Builder() - .sourceEncoding(StandardCharsets.UTF_8) - .outputFormat(XMLOutputFormat.INSTANCE) - .build())); - - } else { - cfgB.setTemplateConfigurations(null); - cfgB.setSettings(loadPropertiesFile("TemplateConfigurationExamples1.properties")); - } - setConfiguration(cfgB.build()); - - addTemplate("t.xml", ""); - - Template t = getConfiguration().getTemplate("t.xml"); - assertEquals(StandardCharsets.UTF_8, t.getActualSourceEncoding()); - assertEquals(XMLOutputFormat.INSTANCE, t.getOutputFormat()); - } - - @Test - public void example2JavaCfg() throws Exception { - example2(true); - } - - @Test - public void example2PropertiesCfg() throws Exception { - example2(false); - } - - private void example2(boolean javaCfg) throws Exception { - TestConfigurationBuilder cfgB = new TestConfigurationBuilder(this.getClass()); - if (javaCfg) { - cfgB.setTemplateConfigurations( - new ConditionalTemplateConfigurationFactory( - new PathGlobMatcher("mail/**"), - new FirstMatchTemplateConfigurationFactory( - new ConditionalTemplateConfigurationFactory( - new FileNameGlobMatcher("*.subject.*"), - new TemplateConfiguration.Builder() - .outputFormat(PlainTextOutputFormat.INSTANCE) - .build()), - new ConditionalTemplateConfigurationFactory( - new FileNameGlobMatcher("*.body.*"), - new TemplateConfiguration.Builder() - .outputFormat(HTMLOutputFormat.INSTANCE) - .build()) - ) - .noMatchErrorDetails( - "Mail template names must contain \".subject.\" or \".body.\"!"))); - } else{ - cfgB.setSettings(loadPropertiesFile("TemplateConfigurationExamples2.properties")); - } - setConfiguration(cfgB.build()); - - addTemplate("t.subject.ftl", ""); - addTemplate("mail/t.subject.ftl", ""); - addTemplate("mail/t.body.ftl", ""); - - Configuration cfg = getConfiguration(); - assertEquals(UndefinedOutputFormat.INSTANCE, cfg.getTemplate("t.subject.ftl").getOutputFormat()); - assertEquals(PlainTextOutputFormat.INSTANCE, cfg.getTemplate("mail/t.subject.ftl").getOutputFormat()); - assertEquals(HTMLOutputFormat.INSTANCE, cfg.getTemplate("mail/t.body.ftl").getOutputFormat()); - } - - @Test - public void example3JavaCfg() throws Exception { - example3(true); - } - - @Test - public void example3PropertiesCfg() throws Exception { - example3(false); - } - - private void example3(boolean javaCfg) throws Exception { - TestConfigurationBuilder cfgB = new TestConfigurationBuilder(this.getClass()) - .sourceEncoding(StandardCharsets.ISO_8859_1); - if (javaCfg) { - cfgB.setTemplateConfigurations( - new MergingTemplateConfigurationFactory( - new ConditionalTemplateConfigurationFactory( - new FileNameGlobMatcher("*.stats.*"), - new TemplateConfiguration.Builder() - .dateTimeFormat("iso") - .dateFormat("iso") - .timeFormat("iso") - .timeZone(_DateUtil.UTC) - .build()), - new ConditionalTemplateConfigurationFactory( - new PathGlobMatcher("mail/**"), - new TemplateConfiguration.Builder() - .sourceEncoding(StandardCharsets.UTF_8) - .build()), - new FirstMatchTemplateConfigurationFactory( - new ConditionalTemplateConfigurationFactory( - new FileExtensionMatcher("xml"), - new TemplateConfiguration.Builder() - .outputFormat(XMLOutputFormat.INSTANCE) - .build()), - new ConditionalTemplateConfigurationFactory( - new OrMatcher( - new FileExtensionMatcher("html"), - new FileExtensionMatcher("htm")), - new TemplateConfiguration.Builder() - .outputFormat(HTMLOutputFormat.INSTANCE) - .build()) - ).allowNoMatch(true))); - } else { - cfgB.setSettings(loadPropertiesFile("TemplateConfigurationExamples3.properties")); - } - setConfiguration(cfgB.build()); - - addTemplate("t.stats.html", "${ts?datetime} ${ts?date} ${ts?time}"); - addTemplate("t.html", ""); - addTemplate("t.htm", ""); - addTemplate("t.xml", ""); - addTemplate("mail/t.html", ""); - - addToDataModel("ts", new Date(1440431606011L)); - - Configuration cfg = getConfiguration(); - assertEquals(HTMLOutputFormat.INSTANCE, cfg.getTemplate("t.html").getOutputFormat()); - assertEquals(StandardCharsets.ISO_8859_1, cfg.getTemplate("t.html").getActualSourceEncoding()); - assertEquals(HTMLOutputFormat.INSTANCE, cfg.getTemplate("t.htm").getOutputFormat()); - assertEquals(XMLOutputFormat.INSTANCE, cfg.getTemplate("t.xml").getOutputFormat()); - assertEquals(HTMLOutputFormat.INSTANCE, cfg.getTemplate("t.stats.html").getOutputFormat()); - assertOutputForNamed("t.stats.html", "2015-08-24T15:53:26.011Z 2015-08-24 15:53:26.011Z"); - assertEquals(StandardCharsets.UTF_8, cfg.getTemplate("mail/t.html").getActualSourceEncoding()); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/UnitAwareTemplateNumberFormatFactory.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/UnitAwareTemplateNumberFormatFactory.java b/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/UnitAwareTemplateNumberFormatFactory.java deleted file mode 100644 index 89f20fa..0000000 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/UnitAwareTemplateNumberFormatFactory.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.freemarker.manualtest; - -import java.util.Locale; - -import org.apache.freemarker.core.Environment; -import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.model.TemplateNumberModel; -import org.apache.freemarker.core.valueformat.TemplateNumberFormat; -import org.apache.freemarker.core.valueformat.TemplateNumberFormatFactory; -import org.apache.freemarker.core.valueformat.TemplateValueFormatException; - -/** - * A number format that takes any other number format as parameter (specified as a string, as - * usual in FreeMarker), then if the model is a {@link UnitAwareTemplateNumberModel}, it shows - * the unit after the number formatted with the other format, otherwise it just shows the formatted - * number without unit. - */ -public class UnitAwareTemplateNumberFormatFactory extends TemplateNumberFormatFactory { - - public static final UnitAwareTemplateNumberFormatFactory INSTANCE - = new UnitAwareTemplateNumberFormatFactory(); - - private UnitAwareTemplateNumberFormatFactory() { - // Defined to decrease visibility - } - - @Override - public TemplateNumberFormat get(String params, Locale locale, Environment env) - throws TemplateValueFormatException { - return new UnitAwareNumberFormat(env.getTemplateNumberFormat(params, locale)); - } - - private static class UnitAwareNumberFormat extends TemplateNumberFormat { - - private final TemplateNumberFormat innerFormat; - - private UnitAwareNumberFormat(TemplateNumberFormat innerFormat) { - this.innerFormat = innerFormat; - } - - @Override - public String formatToPlainText(TemplateNumberModel numberModel) - throws TemplateModelException, TemplateValueFormatException { - String innerResult = innerFormat.formatToPlainText(numberModel); - return numberModel instanceof UnitAwareTemplateNumberModel - ? innerResult + " " + ((UnitAwareTemplateNumberModel) numberModel).getUnit() - : innerResult; - } - - @Override - public boolean isLocaleBound() { - return innerFormat.isLocaleBound(); - } - - @Override - public String getDescription() { - return "unit-aware " + innerFormat.getDescription(); - } - - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/UnitAwareTemplateNumberModel.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/UnitAwareTemplateNumberModel.java b/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/UnitAwareTemplateNumberModel.java deleted file mode 100644 index 1e54254..0000000 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/manualtest/UnitAwareTemplateNumberModel.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.freemarker.manualtest; - -import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.model.TemplateNumberModel; - -public class UnitAwareTemplateNumberModel implements TemplateNumberModel { - - private final Number value; - private final String unit; - - public UnitAwareTemplateNumberModel(Number value, String unit) { - this.value = value; - this.unit = unit; - } - - @Override - public Number getAsNumber() throws TemplateModelException { - return value; - } - - public String getUnit() { - return unit; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-capture.ftlh ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-capture.ftlh b/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-capture.ftlh deleted file mode 100644 index 24bd0ee..0000000 --- a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-capture.ftlh +++ /dev/null @@ -1,21 +0,0 @@ -<#-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---> -<#assign captured><b>Test</b></#assign> -Just a string: ${"<b>Test</b>"} -Captured output: ${captured} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-capture.ftlh.out ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-capture.ftlh.out b/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-capture.ftlh.out deleted file mode 100644 index cf0da7e..0000000 --- a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-capture.ftlh.out +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -Just a string: <b>Test</b> -Captured output: <b>Test</b> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-convert.ftlh ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-convert.ftlh b/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-convert.ftlh deleted file mode 100644 index e0d3348..0000000 --- a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-convert.ftlh +++ /dev/null @@ -1,27 +0,0 @@ -<#-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---> -<#assign mo1 = "Foo's bar {}"?esc> -HTLM: ${mo1} -XML: <#outputformat 'XML'>${mo1}</#outputformat> -RTF: <#outputformat 'RTF'>${mo1}</#outputformat> - -<#assign mo2><p>Test</#assign> -HTML: ${mo2} -XML: <#attempt><#outputformat 'XML'>${mo2}</#outputformat><#recover>Failed</#attempt> -RTF: <#attempt><#outputformat 'RTF'>${mo2}</#outputformat><#recover>Failed</#attempt> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-convert.ftlh.out ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-convert.ftlh.out b/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-convert.ftlh.out deleted file mode 100644 index 65be2a0..0000000 --- a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-convert.ftlh.out +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -HTLM: Foo's bar {} -XML: Foo's bar {} -RTF: Foo's bar \{\} - -HTML: <p>Test -XML: Failed -RTF: Failed http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-convert2.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-convert2.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-convert2.ftl deleted file mode 100644 index 80ae292..0000000 --- a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-convert2.ftl +++ /dev/null @@ -1,25 +0,0 @@ -<#-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---> -<#outputformat "HTML"><#assign htmlMO><p>Test</#assign></#outputformat> -<#outputformat "XML"><#assign xmlMO><p>Test</p></#assign></#outputformat> -<#outputformat "RTF"><#assign rtfMO>\par Test</#assign></#outputformat> -<#-- We assume that we have "undefined" output format here. --> -HTML: ${htmlMO} -XML: ${xmlMO} -RTF: ${rtfMO} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-convert2.ftl.out ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-convert2.ftl.out b/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-convert2.ftl.out deleted file mode 100644 index cd84bd2..0000000 --- a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-convert2.ftl.out +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -HTML: <p>Test -XML: <p>Test</p> -RTF: \par Test \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-infoBox.ftlh ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-infoBox.ftlh b/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-infoBox.ftlh deleted file mode 100644 index 9b8dbd9..0000000 --- a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-infoBox.ftlh +++ /dev/null @@ -1,26 +0,0 @@ -<#-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---> -<@infoBox "Foo & bar" /> -<@infoBox "Foo <b>bar</b>"?no_esc /> - -<#macro infoBox message> - <div class="infoBox"> - ${message} - </div> -</#macro> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-infoBox.ftlh.out ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-infoBox.ftlh.out b/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-infoBox.ftlh.out deleted file mode 100644 index 9471ab7..0000000 --- a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-infoBox.ftlh.out +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - <div class="infoBox"> - Foo & bar - </div> - <div class="infoBox"> - Foo <b>bar</b> - </div> - http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-markup.ftlh ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-markup.ftlh b/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-markup.ftlh deleted file mode 100644 index f9deeae..0000000 --- a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-markup.ftlh +++ /dev/null @@ -1,28 +0,0 @@ -<#-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---> -<#assign markupOutput1="<b>Test</b>"?no_esc> -<#assign markupOutput2="Foo & bar"?esc> - -As expected: -${markupOutput1} -${markupOutput2} - -Double escaping: -${markupOutput1?markup_string} -${markupOutput2?markup_string} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-markup.ftlh.out ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-markup.ftlh.out b/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-markup.ftlh.out deleted file mode 100644 index 0420cca..0000000 --- a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-markup.ftlh.out +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -As expected: -<b>Test</b> -Foo & bar - -Double escaping: -<b>Test</b> -Foo &amp; bar \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-stringConcat.ftlh ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-stringConcat.ftlh b/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-stringConcat.ftlh deleted file mode 100644 index f7884bb..0000000 --- a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-stringConcat.ftlh +++ /dev/null @@ -1,19 +0,0 @@ -<#-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---> -${"<h1>"?no_esc + "Foo & bar" + "</h1>"?no_esc} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-stringConcat.ftlh.out ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-stringConcat.ftlh.out b/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-stringConcat.ftlh.out deleted file mode 100644 index d016072..0000000 --- a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-stringConcat.ftlh.out +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -<h1>Foo & bar</h1> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-stringLiteral.ftlh ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-stringLiteral.ftlh b/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-stringLiteral.ftlh deleted file mode 100644 index 4904f60..0000000 --- a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-stringLiteral.ftlh +++ /dev/null @@ -1,21 +0,0 @@ -<#-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---> -<#assign s = "Foo & bar"> -${s} -${"${s} & baz"} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/abfcac88/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-stringLiteral.ftlh.out ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-stringLiteral.ftlh.out b/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-stringLiteral.ftlh.out deleted file mode 100644 index c6bd10d..0000000 --- a/freemarker-core-test/src/test/resources/org/apache/freemarker/manualtest/AutoEscapingExample-stringLiteral.ftlh.out +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -Foo & bar -Foo & bar & baz \ No newline at end of file
