Comments (6)
Hey @M-Plu,
I'm not entirely sure what you want to try to achieve. Maybe you could provide a code example of what you want to do?
Cheers!
from jte.
Hey @casid
sure. Currently I have JTE files in the project resources. Then I use the following code to create a string output with these files.
CodeResolver codeResolver = new ResourceCodeResolver("de/svws_nrw/module/reporting");
TemplateEngine templateEngine = TemplateEngine.create(codeResolver, ContentType.Html);
templateEngine.setTrimControlStructures(true);
StringOutput output = new StringOutput();
templateEngine.render("jte/schule.jte", reportingSchule, output);
So the CodeResolver needs a folder and the templateEngine.render method needs a file.
What I would like to do is passing a string (with content of a JTE file) to the templateEngine.render method, e. g.
var myString = """
@import ...
@param ..."""
CodeResolver codeResolver = new **String**CodeResolver();
TemplateEngine templateEngine = TemplateEngine.create(codeResolver, ContentType.Html);
templateEngine.setTrimControlStructures(true);
StringOutput output = new StringOutput();
templateEngine.render(**myString**, reportingSchule, output);
I hope that makes sense to you. Thank you for your help.
from jte.
Could you share some details on your use case?
from jte.
Currently we test JTE as a replacement for thymeleaf.
We have created a server-side PDF-Reporting with thymeleaf and OpenHtmlToPDF.
- From the html-template-files we create the html-files with data.
- Then these files are converted to PDF using PrintCSS and OpenHtmlToPDF.
One plan is to store those html-templates in the DB of the project (instead of the resources of teh project). So it would be nice to pass the html-template from DB directly to the template-engine.
With thymeleaf this is possible, in JTE I did not find a way to do the same.
from jte.
@M-Plu you could implement the CodeResolver
interface, so that templates are loaded from the database.
However, I wouldn't recommend jte for your usecase.
First, there probably won't be any IDE support for templates in the database, so maintaining the templates could become easily a pain, since jte without code completion is pretty hard to write. Think of Java without an IDE.
Second, you would need to run a JDK compiler in production. When a bad actor somehow is able to insert a jte template in your database, it will be compiled and you instantly have a remote code execution problem.
jte is really meant to be used in a way like regular code. Part of the repository and precompiled before running in production, like regular Java code.
Hope this helps with your decision!
from jte.
@casid Thank you for your feedback and opinion. We will keep it in mind.
from jte.
Related Issues (20)
- How to use 2 html template and plain text template in same project? HOT 1
- Receive form data in Spring Boot POST request HOT 3
- For Loops won't compile for Kotlin HOT 2
- internationalization with MessageFormat HOT 6
- HTML Comments Inside Content Blocks Cause Compilation Failure in gg.jte.gradle v3.1.7+ HOT 2
- Allow expressions in HTML attribute names for certain types HOT 9
- Spring Boot integration and binary rendering HOT 6
- ${"\\"} Causes "Unexpected end of template expression" HOT 1
- Pass dynamic HTML Content to template HOT 2
- Support JTE project HOT 2
- Failed to compile with module-info.java HOT 2
- Support for read-only filesystem HOT 1
- template define with generic type HOT 1
- Generic template HOT 3
- Html Template Output HOT 2
- Add kotlin and kte documentation HOT 1
- Provide jte-jsp-converter for Jakarta HOT 1
- Comments break JTE HOT 5
- intellij "Cannot resolve MVC view" HOT 4
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 jte.