Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freemarker support cannot handle mixed extension types (ftl, ftlx, ftlh) #889

Open
tfield opened this issue Sep 30, 2024 · 0 comments
Open

Comments

@tfield
Copy link
Contributor

tfield commented Sep 30, 2024

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:

  1. 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
  2. It is possible to <#include> a view of a non-default type - this does work as expected.

Steps To Reproduce

  1. create a new project and include micronaut views and freemarker
  2. create a freemarker view template that has the extension .ftlh
  3. attempt to render the view - fail

Changing the default

  1. configure the micronaut.views.freemarker.default-extension to be ftlh in application.yml
  2. attempt to render the view created above - success
  3. create another route and ftl tmplate as its view
  4. attempt to render the route with the .ftl view - failure

Environment Information

  • macos 14.6 on m1max
  • micronaut 4.4
  • micronaut views
  • freemarker

Example Application

No response

Version

4.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant