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

[Thymeleaf] Support for "Link URLs" #43

Open
mthmulders opened this issue Sep 1, 2016 · 4 comments
Open

[Thymeleaf] Support for "Link URLs" #43

mthmulders opened this issue Sep 1, 2016 · 4 comments

Comments

@mthmulders
Copy link
Contributor

mthmulders commented Sep 1, 2016

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 anIWebContext instance to the Thymeleaf TemplateEngine. Building one requires access to the HttpServletRequest, HttpServletResponse, ServletContext, and optionally Locale. As far as I can see, none of these are available inside TemplateEngine#render. Am I missing the point how to get hold of them?

@mthmulders mthmulders changed the title Access to request, response and servlet context while rendering template [Thymeleaf] Support for "Link URLs" Sep 4, 2016
@mthmulders
Copy link
Contributor Author

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.

@mthmulders
Copy link
Contributor Author

I have a working prototype for this, but it requires perwendel/spark#658 to be merged.

@atomfrede
Copy link

@perwendel It would be awesome to use the IWebContext with thymeleaf3

@mthmulders
Copy link
Contributor Author

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).

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

2 participants