groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Sun (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-4585) backslash can not be escaped by `SimpleTemplateEngine`
Date Fri, 06 Apr 2018 13:46:00 GMT

     [ https://issues.apache.org/jira/browse/GROOVY-4585?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Daniel Sun updated GROOVY-4585:
-------------------------------
    Summary: backslash can not be escaped by `SimpleTemplateEngine`  (was: fix a bug and improve
SimpleTemplateEngine)

> backslash can not be escaped by `SimpleTemplateEngine`
> ------------------------------------------------------
>
>                 Key: GROOVY-4585
>                 URL: https://issues.apache.org/jira/browse/GROOVY-4585
>             Project: Groovy
>          Issue Type: Improvement
>          Components: Templating
>    Affects Versions: 1.8-beta-2
>         Environment: jdk1.6u16, windows xp
>            Reporter: Daniel Sun
>            Priority: Major
>             Fix For: 1.8-beta-4
>
>         Attachments: SimpleTemplateEngine.java.patch, SimpleTemplateEngine.java.v2.patch,
TEST_for_GROOVY-4585.groovy, testcase.v2.zip
>
>
> 1, bug:fail to escape back slash
>   If a back slash(\) in the template, SimpleTemplateEngine can not escape it, as a result,
an exception throwed.
> 2, new feature: add support to escape dollar char
>   Now we can escape dollar char with dollar char, for example: $$
> Enjoy the patch ;)
> {code}
> import groovy.text.*
> String templateContent = new File(/D:\_APPS\groovy_apps\TemplateEnginTest\echo.xml/).text
> def engineForBuildXml = new SimpleTemplateEngine()
> def templateForBuildXml = engineForBuildXml.createTemplate(templateContent)
> String buildXmlContent = templateForBuildXml.make([names:['a', 'b', 'c']]).toString()
> println buildXmlContent
> {code}
> {code}
> <?xml version="1.0" encoding="GB2312"?>
> <project name="projBuild" default="projBuild" basedir=".">
> 	<property name="drive" value="d:\" />
>     <target name="projBuild">
> 		<%for (int i = 0; i < names.size(); i++) {%>
> 			<exec dir="$${drive}" executable="echo">
> 				  <arg line="${names[i]}"/>
> 			</exec>
> 		<%}%>
>     </target>
> </project>
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message