Comments (11)
+1 would love to see this
from thymeleaf.
@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?
from thymeleaf.
I think this is the Velocity servlet that Daniel told about http://velocity.apache.org/tools/devel/view.servlet.html
from thymeleaf.
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 .html
URLs) and redirects them to thymeleaf templates which will do the processing.
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:
- The URL parameters, accessible with
${param.*}
- Our beautiful future shiny SQL dialect :-D defined in #36
And those should be enough to get data to work with in a Thymeleaf-only way...
from thymeleaf.
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.
from thymeleaf.
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 web.xml
files.
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 :)
from thymeleaf.
Oh, that's a nice toy!
I will try it at the end of this week, maybe doing an example application.
Regards,
Zemi
De: Emanuel Rabina [email protected]
Para: thymeleaf/thymeleaf [email protected]
CC: Jose Miguel Samper [email protected]
Enviado: Martes 8 de abril de 2014 11:36
Asunto: Re: [thymeleaf] Create servlet for standalone execution of templates (#35)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 web.xml files.
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 :)
—
Reply to this email directly or view it on GitHub.
from thymeleaf.
@ultraq Oops! I still haven't had a look at that! :-$
from thymeleaf.
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.
from thymeleaf.
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.
from thymeleaf.
👌
from thymeleaf.
Related Issues (20)
- Restricted types no longer usable with th:with in 3.1.2 HOT 2
- Unable to select direct child (using /) HOT 1
- Thymeleaf generated text in TEXT mode replaces CRLF with LF?
- Outputting a JS array outside th:inline script tag HOT 4
- Block to add attributes to included fragments HOT 1
- Do you support CSS3 styles? Like flexbox layout HOT 1
- How to prevent SSTI injection when using hypoleaf in inheriting DispatcherServlet?
- [BUG] using th:field does not work in th:each HOT 1
- GraalVM potential missing reachability metadata
- th:replace by POST response view HOT 1
- BUG: problem with passing Number and String data type to javascript function in thymeleaf looping th:each HOT 3
- Error "Cannot build an application for a request which servlet context does not match with the application that it is being built for." HOT 4
- Cannot use java.util.Currency in expressions
- Migration issue Thymeleaf 3.0.10RELEASE to 3.1.2RELEASE
- when using java 9 modules it doesn't find the template resolver
- Any solution for BDSA-2023-1804? HOT 3
- HTMX integration section in Thymeleaf documentation
- Request for posting of Maven signing key(s) HOT 1
- Replace Variables with issue as empty String HOT 1
- IPostProcessorDialect implementation to minify/remove comments from output html HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thymeleaf.