[jira] [Comment Edited] (FREEMARKER-55) FM3 freemarker-spring module, Web MVC support
[ https://issues.apache.org/jira/browse/FREEMARKER-55?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16086481#comment-16086481 ] Woonsan Ko edited comment on FREEMARKER-55 at 7/13/17 10:08 PM: Yeah, {{org.springframework.web.servlet.view.AbstractTemplateView}} puts the {{RequestContext}} object (by name of {{springMacroRequestContext}}) into {{model}}. As our {{FreemarkerView}} extends it, the attribute should still exist as well in the model. Also, it reminds me that at the moment I probably decided to put {{Request}}, {{Session}}, and {{Application}} variables just like the {{org.springframework.web.servlet.view.freemarker.FreeMarkerView.buildTemplateModel(Map, HttpServletRequest, HttpServletResponse)}} does. was (Author: woon_san): Yeah, {{org.springframework.web.servlet.view.AbstractTemplateView}} puts the {{RequestContext}} object (by name of {{springMacroRequestContext}}) into {{model}}. As our {{FreemarkerView}} extends it, the attribute should still exist as well in the model. > FM3 freemarker-spring module, Web MVC support > - > > Key: FREEMARKER-55 > URL: https://issues.apache.org/jira/browse/FREEMARKER-55 > Project: Apache Freemarker > Issue Type: Task >Affects Versions: 3.0.0 >Reporter: Daniel Dekany > > Add Spring "Web MVC framework" functionality to freemarker-spring. > This can be complex task (and the issue possibly has to be subdivided), as it > involves things like: > * Some aspects of the FreeMarker 2 integration (developed by the Spring > developers) are quite confusing ({{FreemarerConfigurer}}, etc.), and we are > looking into if it needs to be like that. > * See if we can support {{@EnableWebMvc}} (note that FreeMarker 2 support is > hard coded into {{ViewResolverRegistry}}, which we can't modify) > * Creating custom directives/methods to expose Spring features like the > Spring JSP Tag Library does (but in a way that firs FreeMarker better) > * Expose JSP custom tag support from the {{freemarker-servlet}} module. > Depends on: FREEMARKER-54 -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FREEMARKER-55) FM3 freemarker-spring module, Web MVC support
[ https://issues.apache.org/jira/browse/FREEMARKER-55?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16086481#comment-16086481 ] Woonsan Ko commented on FREEMARKER-55: -- Yeah, {{org.springframework.web.servlet.view.AbstractTemplateView}} puts the {{RequestContext}} object (by name of {{springMacroRequestContext}}) into {{model}}. As our {{FreemarkerView}} extends it, the attribute should still exist as well in the model. > FM3 freemarker-spring module, Web MVC support > - > > Key: FREEMARKER-55 > URL: https://issues.apache.org/jira/browse/FREEMARKER-55 > Project: Apache Freemarker > Issue Type: Task >Affects Versions: 3.0.0 >Reporter: Daniel Dekany > > Add Spring "Web MVC framework" functionality to freemarker-spring. > This can be complex task (and the issue possibly has to be subdivided), as it > involves things like: > * Some aspects of the FreeMarker 2 integration (developed by the Spring > developers) are quite confusing ({{FreemarerConfigurer}}, etc.), and we are > looking into if it needs to be like that. > * See if we can support {{@EnableWebMvc}} (note that FreeMarker 2 support is > hard coded into {{ViewResolverRegistry}}, which we can't modify) > * Creating custom directives/methods to expose Spring features like the > Spring JSP Tag Library does (but in a way that firs FreeMarker better) > * Expose JSP custom tag support from the {{freemarker-servlet}} module. > Depends on: FREEMARKER-54 -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FREEMARKER-55) FM3 freemarker-spring module, Web MVC support
[ https://issues.apache.org/jira/browse/FREEMARKER-55?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16086339#comment-16086339 ] Daniel Dekany commented on FREEMARKER-55: - BTW, as of to expose or not to expose the Servlet request and such to templates, seems that the Spring MVC way is accessing such technical objects through {{springMacroRequestContext}}. (I have just bumped into this here: https://stackoverflow.com/questions/45086859/how-to-get-a-request-object-in-freemarker) > FM3 freemarker-spring module, Web MVC support > - > > Key: FREEMARKER-55 > URL: https://issues.apache.org/jira/browse/FREEMARKER-55 > Project: Apache Freemarker > Issue Type: Task >Affects Versions: 3.0.0 >Reporter: Daniel Dekany > > Add Spring "Web MVC framework" functionality to freemarker-spring. > This can be complex task (and the issue possibly has to be subdivided), as it > involves things like: > * Some aspects of the FreeMarker 2 integration (developed by the Spring > developers) are quite confusing ({{FreemarerConfigurer}}, etc.), and we are > looking into if it needs to be like that. > * See if we can support {{@EnableWebMvc}} (note that FreeMarker 2 support is > hard coded into {{ViewResolverRegistry}}, which we can't modify) > * Creating custom directives/methods to expose Spring features like the > Spring JSP Tag Library does (but in a way that firs FreeMarker better) > * Expose JSP custom tag support from the {{freemarker-servlet}} module. > Depends on: FREEMARKER-54 -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FREEMARKER-55) FM3 freemarker-spring module, Web MVC support
[ https://issues.apache.org/jira/browse/FREEMARKER-55?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16086333#comment-16086333 ] Daniel Dekany commented on FREEMARKER-55: - I have commented on the last pull request (#27) on Github... seems Jira doesn't pick it up, so see there. > FM3 freemarker-spring module, Web MVC support > - > > Key: FREEMARKER-55 > URL: https://issues.apache.org/jira/browse/FREEMARKER-55 > Project: Apache Freemarker > Issue Type: Task >Affects Versions: 3.0.0 >Reporter: Daniel Dekany > > Add Spring "Web MVC framework" functionality to freemarker-spring. > This can be complex task (and the issue possibly has to be subdivided), as it > involves things like: > * Some aspects of the FreeMarker 2 integration (developed by the Spring > developers) are quite confusing ({{FreemarerConfigurer}}, etc.), and we are > looking into if it needs to be like that. > * See if we can support {{@EnableWebMvc}} (note that FreeMarker 2 support is > hard coded into {{ViewResolverRegistry}}, which we can't modify) > * Creating custom directives/methods to expose Spring features like the > Spring JSP Tag Library does (but in a way that firs FreeMarker better) > * Expose JSP custom tag support from the {{freemarker-servlet}} module. > Depends on: FREEMARKER-54 -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[GitHub] incubator-freemarker pull request #27: FREEMARKER-55: Add default tld source...
GitHub user woonsan opened a pull request: https://github.com/apache/incubator-freemarker/pull/27 FREEMARKER-55: Add default tld sources You can merge this pull request into a Git repository by running: $ git pull https://github.com/woonsan/incubator-freemarker feature/FREEMARKER-55 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-freemarker/pull/27.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #27 commit 576b0ff3b266da40b26e46a8d66efe6353884a36 Author: Woonsan Ko Date: 2017-07-13T19:42:19Z FREEMARKER-55: Add default tld sources (tld files in web-inf/lib/*.jar) like FreemarkerServlet does. commit 36e04dfceff14d6604067e3e05e59f0cf8b042f7 Author: Woonsan Ko Date: 2017-07-13T19:43:26Z Merge branch '3' into feature/FREEMARKER-55 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[jira] [Commented] (FREEMARKER-55) FM3 freemarker-spring module, Web MVC support
[ https://issues.apache.org/jira/browse/FREEMARKER-55?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16086310#comment-16086310 ] ASF GitHub Bot commented on FREEMARKER-55: -- GitHub user woonsan opened a pull request: https://github.com/apache/incubator-freemarker/pull/27 FREEMARKER-55: Add default tld sources You can merge this pull request into a Git repository by running: $ git pull https://github.com/woonsan/incubator-freemarker feature/FREEMARKER-55 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-freemarker/pull/27.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #27 commit 576b0ff3b266da40b26e46a8d66efe6353884a36 Author: Woonsan Ko Date: 2017-07-13T19:42:19Z FREEMARKER-55: Add default tld sources (tld files in web-inf/lib/*.jar) like FreemarkerServlet does. commit 36e04dfceff14d6604067e3e05e59f0cf8b042f7 Author: Woonsan Ko Date: 2017-07-13T19:43:26Z Merge branch '3' into feature/FREEMARKER-55 > FM3 freemarker-spring module, Web MVC support > - > > Key: FREEMARKER-55 > URL: https://issues.apache.org/jira/browse/FREEMARKER-55 > Project: Apache Freemarker > Issue Type: Task >Affects Versions: 3.0.0 >Reporter: Daniel Dekany > > Add Spring "Web MVC framework" functionality to freemarker-spring. > This can be complex task (and the issue possibly has to be subdivided), as it > involves things like: > * Some aspects of the FreeMarker 2 integration (developed by the Spring > developers) are quite confusing ({{FreemarerConfigurer}}, etc.), and we are > looking into if it needs to be like that. > * See if we can support {{@EnableWebMvc}} (note that FreeMarker 2 support is > hard coded into {{ViewResolverRegistry}}, which we can't modify) > * Creating custom directives/methods to expose Spring features like the > Spring JSP Tag Library does (but in a way that firs FreeMarker better) > * Expose JSP custom tag support from the {{freemarker-servlet}} module. > Depends on: FREEMARKER-54 -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[1/2] incubator-freemarker git commit: Converted test and example ftl files to camel case naming convention
Repository: incubator-freemarker Updated Branches: refs/heads/3 15c6d3817 -> a71567907 http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a7156790/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/sequence-builtins.ftl -- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/sequence-builtins.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/sequence-builtins.ftl index e21bc2d..dc1dbbb 100644 --- a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/sequence-builtins.ftl +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/sequence-builtins.ftl @@ -18,7 +18,7 @@ --> <@noOutput> <#setting locale="en_US"> -<#setting number_format="0.#"> +<#setting numberFormat="0.#"> <#assign ls = []?sort> <#list ls as i> @@ -82,13 +82,13 @@ Sorting hashes: {"name":"beetroot", "weight":0.3} ]> Order by name: -<#assign ls = ls?sort_by("name")> +<#assign ls = ls?sortBy("name")> <#list ls as i> - ${i.name}: ${i.weight} Order by weight: -<#assign ls = ls?sort_by("weight")> +<#assign ls = ls?sortBy("weight")> <#list ls as i> - ${i.name}: ${i.weight} @@ -99,12 +99,12 @@ Order by a.x.v: {"a": {"x": {"v": "aqweqw", "w": "asd"}, "y": '1999-01-20'?date('-MM-dd')}}, {"a": {"x": {"v": "dfgdf", "w": "asd"}, "y": '1999-04-20'?date('-MM-dd')}}, {"a": {"x": {"v": "utyu", "w": "asd"}, "y": '1999-04-19'?date('-MM-dd')}}]> -<#list x?sort_by(['a', 'x', 'v']) as i> +<#list x?sortBy(['a', 'x', 'v']) as i> - ${i.a.x.v} Order by a.y, which is a date: -<#list x?sort_by(['a', 'y']) as i> +<#list x?sortBy(['a', 'y']) as i> - ${i.a.y?string('-MM-dd')} @@ -135,173 +135,173 @@ Contains: <#macro test> <#assign x = [1, "2", true, [1,2,3], {"a":1}, test, '1992-02-21'?date('-MM-dd')]> True: -${x?seq_contains(1.0)?string} -${x?seq_contains("2")?string} -${x?seq_contains(true)?string} -${x?seq_contains('1992-02-21'?date('-MM-dd'))?string} -${abcSet?seq_contains("a")?string} -${abcSet?seq_contains("b")?string} -${abcSet?seq_contains("c")?string} +${x?seqContains(1.0)?string} +${x?seqContains("2")?string} +${x?seqContains(true)?string} +${x?seqContains('1992-02-21'?date('-MM-dd'))?string} +${abcSet?seqContains("a")?string} +${abcSet?seqContains("b")?string} +${abcSet?seqContains("c")?string} False: -${x?seq_contains("1")?string} -${x?seq_contains(2)?string} -${x?seq_contains(false)?string} -${x?seq_contains('1992-02-22'?date('-MM-dd'))?string} -${abcSet?seq_contains("A")?string} -${abcSet?seq_contains(1)?string} -${abcSet?seq_contains(true)?string} +${x?seqContains("1")?string} +${x?seqContains(2)?string} +${x?seqContains(false)?string} +${x?seqContains('1992-02-22'?date('-MM-dd'))?string} +${abcSet?seqContains("A")?string} +${abcSet?seqContains(1)?string} +${abcSet?seqContains(true)?string} <#assign x = []> -False: ${x?seq_contains(1)?string} +False: ${x?seqContains(1)?string} Index_of: - <#assign x = [1, "2", true, [1,2,3], {"a":1}, test, '1992-02-21'?date('-MM-dd')]> -0 = ${x?seq_index_of(1.0)} -1 = ${x?seq_index_of("2")} -2 = ${x?seq_index_of(true)} -6 = ${x?seq_index_of('1992-02-21'?date('-MM-dd'))} -0 = ${abcSet?seq_index_of("a")} -1 = ${abcSet?seq_index_of("b")} -2 = ${abcSet?seq_index_of("c")} - --1 = ${x?seq_index_of("1")} --1 = ${x?seq_index_of(2)} --1 = ${x?seq_index_of(false)} --1 = ${x?seq_index_of('1992-02-22'?date('-MM-dd'))} --1 = ${abcSet?seq_index_of("A")} --1 = ${abcSet?seq_index_of(1)} --1 = ${abcSet?seq_index_of(true)} +0 = ${x?seqIndexOf(1.0)} +1 = ${x?seqIndexOf("2")} +2 = ${x?seqIndexOf(true)} +6 = ${x?seqIndexOf('1992-02-21'?date('-MM-dd'))} +0 = ${abcSet?seqIndexOf("a")} +1 = ${abcSet?seqIndexOf("b")} +2 = ${abcSet?seqIndexOf("c")} + +-1 = ${x?seqIndexOf("1")} +-1 = ${x?seqIndexOf(2)} +-1 = ${x?seqIndexOf(false)} +-1 = ${x?seqIndexOf('1992-02-22'?date('-MM-dd'))} +-1 = ${abcSet?seqIndexOf("A")} +-1 = ${abcSet?seqIndexOf(1)} +-1 = ${abcSet?seqIndexOf(true)} <#assign x = []> --1 = ${x?seq_index_of(1)} +-1 = ${x?seqIndexOf(1)} Last_index_of: -- <#assign x = [1, "2", true, [1,2,3], {"a":1}, test, 1, '1992-02-21'?date('-MM-dd')]> -6 = ${x?seq_last_index_of(1.0)} -1 = ${x?seq_last_index_of("2")} -2 = ${x?seq_last_index_of(true)} -7 = ${x?seq_last_index_of('1992-02-21'?date('-MM-dd'))} --1 = ${x?seq_last_index_of("1")} -0 = ${abcSet?seq_last_index_of("a")} -1 = ${abcSet?seq_last_index_of("b")} -2 = ${abcSet?seq_last_index_of("c")} --1 = ${abcSet?seq_last_index_of("A")} +6 = ${x?seqLastIndexOf(1.0)} +1 = ${x?seqLastIndexOf("2")} +2 = ${x?seqLastIndexOf(true)} +7 = ${x?seqLastIndexOf('1992-02-21'?date('-MM-dd'))} +-1 = ${x?seqLastIndexOf("1")} +0
[2/2] incubator-freemarker git commit: Converted test and example ftl files to camel case naming convention
Converted test and example ftl files to camel case naming convention Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/a7156790 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/a7156790 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/a7156790 Branch: refs/heads/3 Commit: a71567907df9c96dd78bf0944ed31ac6d415ccdd Parents: 15c6d38 Author: ddekany Authored: Thu Jul 13 21:14:08 2017 +0200 Committer: ddekany Committed: Thu Jul 13 21:14:40 2017 +0200 -- .../org/apache/freemarker/core/ast-builtins.ast | 8 +- .../org/apache/freemarker/core/ast-builtins.ftl | 4 +- .../apache/freemarker/core/ast-locations.ftl| 4 +- .../org/apache/freemarker/core/ast-range.ast| 8 +- .../org/apache/freemarker/core/ast-range.ftl| 2 +- .../apache/freemarker/core/cano-builtins.ftl| 4 +- .../freemarker/core/cano-builtins.ftl.out | 4 +- .../core/cano-identifier-escaping.ftl | 8 +- .../core/cano-identifier-escaping.ftl.out | 4 +- .../templatesuite/templates/api-builtins.ftl| 16 +- .../templates/boolean-formatting.ftl| 24 +- .../templates/date-type-builtins.ftl| 46 +-- .../templates/dateformat-iso-bi.ftl | 228 +++--- .../templates/dateformat-iso-like.ftl | 46 +-- .../templatesuite/templates/dateformat-java.ftl | 16 +- .../templatesuite/templates/dateparsing.ftl | 30 +- .../core/templatesuite/templates/escapes.ftl| 22 +- .../templates/existence-operators.ftl | 40 +-- .../templatesuite/templates/hashliteral.ftl | 4 +- .../templates/identifier-escaping.ftl | 8 +- .../core/templatesuite/templates/if.ftl | 42 +-- .../core/templatesuite/templates/include2.ftl | 12 +- .../templatesuite/templates/lastcharacter.ftl | 2 +- .../core/templatesuite/templates/macros.ftl | 4 +- .../core/templatesuite/templates/noparse.ftl| 16 +- .../templatesuite/templates/number-format.ftl | 4 +- .../templatesuite/templates/number-literal.ftl | 2 +- .../templates/number-math-builtins.ftl | 60 ++-- .../templatesuite/templates/number-to-date.ftl | 22 +- .../templatesuite/templates/numerical-cast.ftl | 2 +- .../templates/output-encoding1.ftl | 8 +- .../templates/output-encoding2.ftl | 6 +- .../templates/output-encoding3.ftl | 6 +- .../core/templatesuite/templates/root.ftl | 6 +- .../templates/sequence-builtins.ftl | 240 +++ .../core/templatesuite/templates/setting.ftl| 26 +- .../templatesuite/templates/specialvars.ftl | 10 +- .../templates/string-builtin-coercion.ftl | 14 +- .../string-builtins-regexps-matches.ftl | 2 +- .../templates/string-builtins-regexps.ftl | 6 +- .../templates/string-builtins1.ftl | 60 ++-- .../templates/string-builtins2.ftl | 184 ++-- .../templates/string-builtins3.ftl | 296 +-- .../templatesuite/templates/stringbimethods.ftl | 8 +- .../templatesuite/templates/type-builtins.ftl | 32 +- .../core/templatesuite/templates/url.ftl| 6 +- .../core/templatesuite/templates/var-layers.ftl | 8 +- .../core/templatesuite/templates/varargs.ftl| 4 +- .../core/templatesuite/templates/variables.ftl | 2 +- .../templatesuite/templates/varlayers_lib.ftl | 6 +- .../templates/wsstripinheader_inc.ftl | 2 +- .../templates/wstrip-in-header.ftl | 2 +- .../templatesuite/templates/default-xmlns.ftl | 2 +- .../templatesuite/templates/xml-fragment.ftl| 8 +- .../templates/xml-ns_prefix-scope-lib.ftl | 2 +- .../templates/xml-ns_prefix-scope-main.ftl | 2 +- .../dom/templatesuite/templates/xmlns1.ftl | 2 +- .../dom/templatesuite/templates/xmlns3.ftl | 12 +- .../dom/templatesuite/templates/xmlns4.ftl | 12 +- .../dom/templatesuite/templates/xmlns5.ftl | 2 +- .../examples/AutoEscapingExample-convert.ftlh | 8 +- .../examples/AutoEscapingExample-convert2.ftl | 6 +- .../examples/AutoEscapingExample-infoBox.ftlh | 2 +- .../examples/AutoEscapingExample-markup.ftlh| 6 +- .../AutoEscapingExample-stringConcat.ftlh | 2 +- .../AutoEscapingExample-stringLiteral2.ftlh | 2 +- 66 files changed, 847 insertions(+), 847 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a7156790/freemarker-core-test/src/test/resources/org/apache/freemarker/core/ast-builtins.ast -- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/ast
incubator-freemarker git commit: Continued working on FM2 to FM3 converter...
Repository: incubator-freemarker Updated Branches: refs/heads/3 7991d3e54 -> 15c6d3817 Continued working on FM2 to FM3 converter... Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/15c6d381 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/15c6d381 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/15c6d381 Branch: refs/heads/3 Commit: 15c6d381736657b0b64792dae745881f05d9e6a4 Parents: 7991d3e Author: ddekany Authored: Thu Jul 13 20:45:20 2017 +0200 Committer: ddekany Committed: Thu Jul 13 20:45:20 2017 +0200 -- .../core/FM2ASTToFM3SourceConverter.java| 142 ++- .../apache/freemarker/converter/Converter.java | 17 ++- .../freemarker/converter/FM2ToFM3Converter.java | 47 +- .../converter/FM2ToFM3ConverterTest.java| 44 -- .../apache/freemarker/core/util/FTLUtil.java| 27 +++- .../jsp/webapps/errors/failing-parsetime.ftlnv | 2 +- 6 files changed, 220 insertions(+), 59 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/15c6d381/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java -- diff --git a/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java b/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java index d8f5225..e4a3e12 100644 --- a/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java +++ b/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java @@ -19,6 +19,9 @@ package freemarker.core; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.Reader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -28,6 +31,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.commons.io.IOUtils; import org.apache.freemarker.converter.ConversionMarkers; import org.apache.freemarker.converter.ConverterException; import org.apache.freemarker.converter.ConverterUtils; @@ -40,6 +44,8 @@ import org.apache.freemarker.core.util._StringUtil; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import freemarker.cache.StringTemplateLoader; +import freemarker.cache.TemplateLoader; import freemarker.template.Configuration; import freemarker.template.Template; import freemarker.template.utility.StringUtil; @@ -75,6 +81,7 @@ import freemarker.template.utility.StringUtil; public class FM2ASTToFM3SourceConverter { private final Template template; +private final StringTemplateLoader overlayTemplateLoader; private final String src; private final ConversionMarkers markers; @@ -94,9 +101,10 @@ public class FM2ASTToFM3SourceConverter { * {@code false}. */ public static Result convert( -String templateName, String src, Configuration fm2Cfg, ConversionMarkers warnReceiver) +Template template, Configuration fm2Cfg, StringTemplateLoader overlayTemplateLoader, +ConversionMarkers warnReceiver) throws ConverterException { -return new FM2ASTToFM3SourceConverter(templateName, src, fm2Cfg, warnReceiver).convert(); +return new FM2ASTToFM3SourceConverter(template, fm2Cfg, overlayTemplateLoader, warnReceiver).convert(); } private Result convert() throws ConverterException { @@ -106,16 +114,30 @@ public class FM2ASTToFM3SourceConverter { } private FM2ASTToFM3SourceConverter( -String templateName, String src, Configuration fm2Cfg, ConversionMarkers warnReceiver) +Template template, Configuration fm2Cfg, StringTemplateLoader overlayTemplateLoader, +ConversionMarkers warnReceiver) throws ConverterException { -template = createTemplate(templateName, src, fm2Cfg); -if (template.getParserConfiguration().getWhitespaceStripping()) { -throw new IllegalArgumentException("The Template must have been parsed with whitespaceStripping false."); -} +this.template = template; +this.overlayTemplateLoader = overlayTemplateLoader; -_NullArgumentException.check("src", src); +try { +TemplateLoader templateLoader = fm2Cfg.getTemplateLoader(); +Object templateSource = templateLoader.findTemplateSource(template.getName()); +if (templateSource == null) { +throw new FileNotFoundException("Template not found: " + template.getName()); +} -this.src = src; +Reader reader = templateLoader.getRea