apache / apache/grails-core

raw()Methode doesn't work with included controller's view (Grails 4.0.x)

Open
#11,717 6 comments 1 reaction 0 assignees View on GitHub
type: bug
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

When a view includes a controller with the raw() methode doesn't work anymore inside the included controller's view.

### Steps to Reproduce

Create a view and include a controller:
``

RawContentController:
```
class RawContentController {

def index() {
def content = "sample with included content"
render(view: "index", model: [content: content])
}
}
```
rawContent/index.gsp:
`

${raw(content)}
`

### Expected Behaviour
The raw HTML should be included in the view rather than an escaped string.
The output should be:
_sample with included_ content

### Actual Behaviour
This is not working with Grails 4.0.x, but it is working with Grails 2.x/Grails 3.x
With Grails 4.0.x the raw() methode still deliver the escaped string:
`sample with included content`

### Workaround
Create & using a TagLib is working:
```
class ContentTagLib {
static defaultEncodeAs = [taglib:'html']
static encodeAsForTags = [rawOutput: [taglib:'raw']]
static namespace = "myapp"

def rawOutput = {attrs ->
String html = attrs['html']
out << html
}
}
```
rawContent/index.gsp::
`

`

### Environment Information

- **Operating System**: all
- **Grails Version:** 4.0.x
- **JDK Version:** all

### Example Application
https://github.com/DontPlayTheGame/example-grails406
But i included this in all example apps in: https://github.com/DontPlayTheGame?tab=repositories

Contributor guide

Open the contributing guide

Research direction

Start with the linked example application, then reproduce the issue using RawContentController and rawContent/index.gsp with g:include and raw(content). Trace the rendering behavior for the included view and raw() handling; done means the included HTML renders unescaped in Grails 4.0.x, matching the expected output.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.