The render function called by ScriptTemplateView has currently 3 parameters provided:
- String template: the content of the template resource
- Map<String, Object>: the model to use to render the view
- String url: the url of the 2 view
To achieve i18n support for messages and nested template loading, we need to provide these additional informations:
- a ResourceBundleMessageSource instance (or the ApplicationContext that allows to retrieve it)
- the view Locale
- a Function<String, String> that allows the render function to call ScriptTemplateView#getTemplate(String)
I see mainly 2 ways to support that:
1) We could be possible leverage setExposeContextBeansAsAttributes() or setExposedContextBeanNames() to access to context beans and expose them via model attributes.
2) We could transform the 3rd parameter passed to the script function (currently String url) to RenderingContext that would contains String url, Locale locale, ResourceBundleMessageSource messageSource and Function<String, String> templateLoader properties. This would be a breaking change for people using `url` but ScriptTemplateView is a rather feature, and url is not widely used, so I consider this as an option in order to be consistent and provide such flexible mechanism for further needs + it provides these properties in a type-safe way which would be valuable for Kotlin JSR-223 support.