Skip to content

Improve FreeMarker macro support in spring-webflux #23105

@sbrannen

Description

@sbrannen

Overview

This issue is a followup to gh-23002.

The documentation for spring.ftl in spring-webflux states the following.

To take advantage of these macros, the "requestContextAttribute" property of the FreeMarkerView class must be set to "springMacroRequestContext". This will expose a RequestContext under the name "springMacroRequestContext", as needed by the macros in this library.

Although this technically works, it is not as user-friendly as the analogous support in spring-webmvc. Specifically, AbstractTemplateView (in spring-webmvc) provides a dedicated exposeSpringMacroHelpers flag for automatically exposing the RequestContext as a model attribute for consumption in FreeMarker templates. Since this boolean flag defaults to true, users do not have to configure anything special in FreeMarkerView to use all supported macros.

In contrast, users of FreeMarkerView in spring-webflux cannot use all supported macros unless they explicitly set the requestContextAttribute property of the FreeMarkerView to "springMacroRequestContext".

I think this is cumbersome and should be improved.

Deliverables

  • Consider introducing a dedicated exposeSpringMacroHelpers flag in template-based views in spring-webflux analogous to the support in spring-webmvc.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions