[
https://issues.apache.org/jira/browse/FREEMARKER-184?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17377143#comment-17377143
]
Dániel Dékány commented on FREEMARKER-184:
------------------------------------------
Check which template you are actually loading. The one you show has no "#if
something". Also, you miss the actual error message; you just show the trace.
> @compress report error
> ----------------------
>
> Key: FREEMARKER-184
> URL: https://issues.apache.org/jira/browse/FREEMARKER-184
> Project: Apache Freemarker
> Issue Type: Bug
> Affects Versions: 2.3.30
> Reporter: laram
> Priority: Minor
>
> Use <@compress single_line=true>...</@compress> to report an error
>
> I use the native freemarker to define a template
>
> {code:java}
> <html>
> <head>
> <meta charset="utf-8">
> <title>Freemarker DEMO </title>
> </head>
> <body>
> ${name},hello。${message}
> <@compress single_line=true>
> "First cell"
> |"Third cell"
> </@compress>
> </body>
> </html>
> {code}
> Parse the template as follows:
>
> {code:java}
> public static void main(String[] args) throws Exception {
> // 1.设置配置类
> Configuration configuration = new
> Configuration(Configuration.getVersion());
> //2. 设置模板所在的目录
> configuration.setDirectoryForTemplateLoading(
> new File("D:/xxxx/2020/"));
> //3.设置字符集
> configuration.setDefaultEncoding("utf-8");
> //4.加载模板
> Template template = configuration.getTemplate("test.html");
> //5.创建数据模型
> HashMap map = new HashMap();
> map.put("name", "周杰伦");
> map.put("message", "我是你的老歌迷了");
> //6.创建Writer对象
> FileWriter writer = new FileWriter(new File("D:/data/xxxx/as.html"));
> //7.输出数据模型到文件中
> template.process(map, writer);
> //8.关闭Writer对象
> writer.close();
> }
> {code}
> Will report an error
> {code:java}
> FTL stack trace ("~" means nesting-related):
> - Failed at: #if something [in template "test.html" at line 11, column
> 1]
> - Reached through: @compress single_line=true [in template "test.html"
> at line 9, column 1]
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)