Prevent html encoding in TemplateMode.TEXT

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Prevent html encoding in TemplateMode.TEXT

rsomasunderam@netflix.com
Hi,

I'm not sure if I've run into a bug or I'm using this incorrectly. I'm trying to generate text output, and I'm seeing Thymeleaf html encode my params.

This is the minimal groovy code to reproduce it

```
@Grab(group='org.thymeleaf', module='thymeleaf', version='3.0.11.RELEASE')
import org.thymeleaf.TemplateEngine
import org.thymeleaf.TemplateSpec
import org.thymeleaf.context.Context
import org.thymeleaf.templatemode.TemplateMode

def context = new Context()
context.setVariable('foo', 'a && b')

TemplateEngine engine = new TemplateEngine()
def template = '''\
    foo: '[[${foo}]]'
    '''.stripIndent()
println engine.process(new TemplateSpec(template, TemplateMode.TEXT), context)
```

I am expecting to see

```
foo: 'a && b'
```

However, I'm seeing

```
foo: 'a && b'
```

[Edit] Nabble is formatting it weirdly now. I'm getting the html escaped & in my output

Is there a better way to prevent html encoding?
Should I raise a bug?
Reply | Threaded
Open this post in threaded view
|

Re: Prevent html encoding in TemplateMode.TEXT

rsomasunderam@netflix.com
Never mind, after sufficient googling, I found https://github.com/thymeleaf/thymeleaf/issues/524