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

Daniel Sun updated GROOVY-4585:
-------------------------------
    Fix Version/s:     (was: 1.8-beta-4)
                   2.5.0-rc-2
                   2.4.16
                   2.6.0-alpha-4
                   3.0.0-alpha-2

> 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: 3.0.0-alpha-1, 2.6.0-alpha-3, 2.5.0-rc-1, 2.4.15
>         Environment: jdk1.6u16, windows xp
>            Reporter: Daniel Sun
>            Assignee: Daniel Sun
>            Priority: Major
>             Fix For: 3.0.0-alpha-2, 2.6.0-alpha-4, 2.4.16, 2.5.0-rc-2
>
>         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)

Reply via email to