Git Product home page Git Product logo

Comments (2)

anentropic avatar anentropic commented on August 28, 2024

Hmm... looks like JinjaX keeps its own internal Jinja env though, so maybe to the outer template the JinjaX component is a black box, which is going to load and render its own templates at render time

from jinjax.

jpsca avatar jpsca commented on August 28, 2024

JinjaX currently works as a pre-processor, replacing all:

<Component attr="value">content</Component>

with function calls like:

{% call catalog.irender("Component", attr="value") %}content{% endcall %}

These calls are evaluated at render time. Each call loads the source of the component file, parses it to extract the names of CSS/JS files, required and/or optional attributes, pre-processes the template (replacing components with function calls, as before), and finally renders the new template.

The rendering still uses the Jinja cache, but the loading and parsing did not, as it was repeated multiple times if a component was used multiple times (like a <Button>). Hence, I added a custom cache in #30. The Jinja cache is still used when rendering the template.

The custom cache depends on the modified time of the component files. If you know the component file is not going to change while the application is running, such as in a production environment, you can create the catalog with auto_reload=False to deactivate the check.

I don't think the situation is bad for production... but it could be better by having a catalog.compile_templates() function that could insert the code of the components recursively, instead of just a call, so we could rely only in the Jinja cache.

from jinjax.

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.