You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Jochen Theodorou (JIRA)" <ji...@apache.org> on 2017/01/10 18:51:58 UTC

[jira] [Commented] (GROOVY-8041) The templating engine does not handle properly the binding parameters that contains dot ('.') character

    [ https://issues.apache.org/jira/browse/GROOVY-8041?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15815832#comment-15815832 ] 

Jochen Theodorou commented on GROOVY-8041:
------------------------------------------

something like this I did mean
{code:Java}
def template = new groovy.text.SimpleTemplateEngine().createTemplate('Testing ${this."a.b"}

')
{code}

you already confirmed that properties["a.b"] works... as would properties."a.b". As long as the lookup is going through "this" (implicit or explicit), which delegates then to properties, as long as that is the case, the proposed solution should work. Overwise... instead of using properties to configure e values of the template, use a map like [myProperties:properties] to do it and then {code:Java}
def template = new groovy.text.SimpleTemplateEngine().createTemplate('Testing ${myProperties."a.b"}

')
{code}

> The templating engine does not handle properly the binding parameters that contains dot ('.') character
> -------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-8041
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8041
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.7
>            Reporter: Bence Takács
>            Assignee: Jochen Theodorou
>
> The templating engine does not handle properly the binding parameters that contains dot ('.') character
> The below script throws an exception while the assertion passes:
> def template = new groovy.text.SimpleTemplateEngine().createTemplate('Testing ${a.b}')
> def params = ['a.b':'working']
> assert params['a.b']
> println template.make(params)
> "groovy.lang.MissingPropertyException: No such property: a for class: SimpleTemplateScript22
> 	at SimpleTemplateScript22.run(SimpleTemplateScript22.groovy:1)
> 	at Script1.run(Script1.groovy:5)"
> The issue is valid for also StreamingTemplateEngine and GStringTemplateEngine



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)