-
Notifications
You must be signed in to change notification settings - Fork 493
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
Create servlet for standalone execution of templates #35
Comments
+1 would love to see this |
@danielfernandez What kind of servlet do you envision for this? I already run a Spring-less Thymeleaf site, so I could just extract my template servlet into its own library (much like I did with the layout dialect) or as an extra? |
I think this is the Velocity servlet that Daniel told about http://velocity.apache.org/tools/devel/view.servlet.html |
Basically, I thought of this as a way to create thymeleaf-only web applications in a similar fashion to the way people can create ASP-only web applications on an IIS or JSP-only web applications on a Tomcat/Jetty/whatever. This is, a servlet that takes URLs (probably only And what processing, you might ask, if by the time we have our thymeleaf template executing itself we will have no context at all? Correct, but we will have two things:
And those should be enough to get data to work with in a Thymeleaf-only way... |
I'll see what I can get going for this sometime this week as well. I'll just throw it into one of my own repos for you to evaluate. I should also be able to get it working much more simply than the instructions on the Velocity page if I start with using Servlet 3.0 web fragments (sooo much easier than having to hack together the web.xml yourself), or maybe I'm just being too optimistic. |
So I got something going in this repo: https://github.com/ultraq/thymeleaf-template-servlet It's a web fragment project, so can be imported into any web project and it'll automatically start working as per the config in the annotations here: StandaloneThymeleafServlet.java So the web container should support the Java web app 3.0 spec, and have annotation scanning turned on. (It shouldn't be too hard to create a non-annotation version, but I just went down this route because it's the easiest to get something going.) The init-params can also be overridden by developers in their I created a mini web app (it's an Eclipse project, so is pretty hard to share right now) that imported this project and then had just HTML files in the web content folder. I could then go http://localhost:8080/test-project/path-to-html-file.html and voila! Thymeleaf template :) |
Oh, that's a nice toy! I will try it at the end of this week, maybe doing an example application. Regards,
|
@ultraq Oops! I still haven't had a look at that! :-$ |
The standalone servlet was integrated in the example app at https://github.com/jmiguelsamper/thymeleaf-extras-sqldialect which now is listed on the ecosystem page. The only outstanding question is whether integrate the servlet into the Thymeleaf core or not. |
I think it shouldn't be core, and just get a mention in the ecosystem page like your SQL dialect and then we'll support them like we do with our other Thymeleaf add-on projects. |
👌 |
A specific servlet could enable the standalone execution of thymeleaf templates (à la JSP) for those users that do not want to have any controller-side frameworks. Velocity has something similar to this...
The text was updated successfully, but these errors were encountered: