Code Monkey home page Code Monkey logo

Comments (6)

casid avatar casid commented on August 15, 2024

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.

mtdowling avatar mtdowling commented on August 15, 2024

My use case is code generation, so whitespace is super important for me. Thanks for clarifying.

from jte.

casid avatar casid commented on August 15, 2024

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.

edrd-f avatar edrd-f commented on August 15, 2024

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.

casid avatar casid commented on August 15, 2024

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.

edrd-f avatar edrd-f commented on August 15, 2024

I see. Thanks for the explanation!

from jte.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.