You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Andrew Malyhin (Jira)" <ji...@apache.org> on 2021/02/23 20:57:00 UTC
[jira] [Commented] (GROOVY-8701) StreamingTemplateEngine renders
escaped character with backslash
[ https://issues.apache.org/jira/browse/GROOVY-8701?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17289329#comment-17289329 ]
Andrew Malyhin commented on GROOVY-8701:
----------------------------------------
Unfortunately I've faced the same issue with version 3.0.7.
> StreamingTemplateEngine renders escaped character with backslash
> ----------------------------------------------------------------
>
> Key: GROOVY-8701
> URL: https://issues.apache.org/jira/browse/GROOVY-8701
> Project: Groovy
> Issue Type: Bug
> Components: Templating
> Affects Versions: 2.5.1
> Reporter: Szymon Stępniak
> Priority: Minor
>
> Using {{groovy.text.StreamingTemplateEngine}} to render a template containing escaped character (e.g. {{\$}}) produces output containing escape character. Using the same template with {{groovy.text.GStringTemplateEngine}} does not produce an output containing escape character.
> The quickest way to reproduce the issue:
>
> {code}
> import groovy.text.StreamingTemplateEngine
> def placeholders = [
> "StreamingTemplateEnginePlaceholder": "SOME_VALUE",
> ]
> def templateContent = new File('test.php.template').text
> def engine = new StreamingTemplateEngine()
> def configContent = engine.createTemplate(templateContent)
> .make(placeholders)
> .toString()
> println configContent
> {code}
> test.php.template
> {code:php}
> <?php
> \$my_php_config_variable = "${StreamingTemplateEnginePlaceholder}"
> ?>
> {code}
> Output:
> {code:php}
> <?php
> \$my_php_config_variable = "SOME_VALUE"
> ?>
> {code}
> When template does not escape dollar character then rendering such a template produces following exception:
> {code:bash}
> Caught: groovy.text.TemplateExecutionException: Template execution error at line 2:
> 1: <?php
> --> 2: $my_php_config_variable = "${StreamingTemplateEnginePlaceholder}"
> 3: ?>
> groovy.text.TemplateExecutionException: Template execution error at line 2:
> 1: <?php
> --> 2: $my_php_config_variable = "${StreamingTemplateEnginePlaceholder}"
> 3: ?>
> at test.run(test.groovy:9)
> Caused by: groovy.lang.MissingPropertyException: No such property: my_php_config_variable for class: groovy.tmp.templates.StreamingTemplateScript1
> ... 1 more
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)