Open mthmulders opened 8 years ago
This might be less difficiult after upgrading to Thymeleaf 3, since the Thymeleaf 3 ten-minute migration guide states that Thymeleaf 3 is capable of running
truly independent from the Servlet API in web environments that do not make use of Java Servlets
Although Spark does use the Servlet API under the hood, it might be easier to use the aforementioned features with Thymeleaf 3 than it currently is with Thymeleaf 2.
I have a working prototype for this, but it requires https://github.com/perwendel/spark/pull/658 to be merged.
@perwendel It would be awesome to use the IWebContext
with thymeleaf3
I have a working prototype for this, but it requires perwendel/spark#658 to be merged.
Note to future self... The prototype involves extending Thymeleaf's StandardLinkBuilder
, overriding the computeContextPath()
method to use ServletFlag.getContextPath()
(introduced with perwendel/spark#658).
Thymeleaf has some nice features when it comes to rendering (hyper)links. It would be cool if we could use these from Spark applications as well.
But to use these features, one needs to supply an
IWebContext
instance to the ThymeleafTemplateEngine
. Building one requires access to theHttpServletRequest
,HttpServletResponse
,ServletContext
, and optionallyLocale
. As far as I can see, none of these are available insideTemplateEngine#render
. Am I missing the point how to get hold of them?