-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Labels
Description
Expected Behavior
Freemarker supports several extension types, ftl, ftlx, and ftlh. The x and h variants activate automatic escaping for xml and html respectively.
While it is possible to change the default extension for Freemarker, it is not possible to dispatch to a view that is anything other than the default. Developers should be free to choose .ftl, .ftlx, or .ftlh as the view from within controllers, on a case-by-case basis.
Actual Behaviour
Extensions other than the default extension are not found, returning a view not found error.
This appears to be due to the viewLocation method of FreemarkerViewsRenderer always normalizing the extension to the default value.
Note:
- It is possible to change the default extension via configuration, which allows controllers to dispatch to a different format, but this is a global change
- It is possible to
<#include>a view of a non-default type - this does work as expected.
Steps To Reproduce
- create a new project and include micronaut views and freemarker
- create a freemarker view template that has the extension
.ftlh - attempt to render the view - fail
Changing the default
- configure the
micronaut.views.freemarker.default-extensionto beftlhinapplication.yml - attempt to render the view created above - success
- create another route and
ftltmplate as its view - attempt to render the route with the
.ftlview - failure
Environment Information
- macos 14.6 on m1max
- micronaut 4.4
- micronaut views
- freemarker
Example Application
No response
Version
4.4