raw()Methode doesn't work with included controller's view (Grails 4.0.x)
- 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:
`
### 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
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