Is there any way to use Thymeleaf in grails instead of GSPs?

142 Views Asked by At

I am building an application with react+grails, where grails is the wrapper. However, the react application is based on Create React App, due to this the output template of react is index.html. However, grails don't allow rendering .html files. So, is there anyway to use thymeleaf instead of gsp ?

I have other ways like render text: htmlText, contentType:"text/html", encoding:"UTF-8" but this seems very hacky.

1

There are 1 best solutions below

1
Jeff Scott Brown On

So, is there anyway to use thymeleaf instead of gsp ?

Yes. One way to do that is to use the Spring Boot Thymeleaf support.

However, grails don't allow rendering .html files

That isn't true. We render .html files all the time. You can render any static file from a Grails app, including .html files.

EDIT:

See the project at github.com/jeffbrown/ganeshkhadkahtml.

If you run that app and send a request to http://localhost:8080/showMeSomeHtml that will render the HTML file at src/main/webapp/static/index.html.

You could also send a request to http://localhost:8080/static/index.html to render that same file if you wanted to support that.