Comments (6)
Hey @mtdowling, this isn't possible at the moment. Every template is precompiled independently from where it is called from. For rendering Html this isn't an issue, which is the primary use case of jte (for me). For Html, I'd love to add compile-time Html compression as a feature some day: #10
I added an experimental mode to trim the jte control structures from the output (TemplateEngine#setTrimControlStructures
), that tries to remove extra indentations by jte control structures like @if
, @for
and so on. But that's still very experimental. And it doesn't solve the problem you describe.
May I ask what type of content you'd like to generate with jte?
from jte.
My use case is code generation, so whitespace is super important for me. Thanks for clarifying.
from jte.
You're welcome. Yeah, I think for perfect control over whitespaces jte is not the right tool. I did some improvements to #10 over the weekend, but the moment you extract functionality in a tag the whitespaces will be different.
from jte.
Was about to open an issue for the same reason as this one. Glad I didn't.
I see a lot of potential in JTE for general code generation, but some languages are very indentation-sensitive (e.g. YAML, Python and even Scala 3).
@casid when you said:
Yeah, I think for perfect control over whitespaces jte is not the right tool.
You meant "at the current state but maybe in the future it will be" or "it's not intended for such use cases"? 😁
If you meant the former, we could discuss and I could help implement it (maybe even in a manner that also advances the implementation of #10).
from jte.
It is not really intended for perfect white space control. The reason jte was created was primarily to renderer HTML as fast and secure as possible. In order to carry indentations over to tags, we'd somehow need to pass that as a parameter to the tag. That tag indentation would need to be evaluated at runtime and that will add unnecesary overhead to HTML rendering.
from jte.
I see. Thanks for the explanation!
from jte.
Related Issues (20)
- Automatically call `.toString()` when outputting unknown types? HOT 4
- The ` syntax in the <script> tag in a jte extension file doesn't work. HOT 1
- error template resolution Spring Boot HOT 3
- Bug in StringUtils.startsWithIgnoringCaseAndWhitespaces() prevents writing out "J" HOT 4
- Initial response time is slower on first request than on subsequent requests HOT 2
- Potential escaping optimization HOT 7
- Backticks in comments end the content block
- Question: Dynamicially Compiled Tempates on Application Servers HOT 3
- 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
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.