-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion for a new feature - Template Fragments #159
Comments
Can you please share a technical proposal of how it will work? More specifically, when you want to render a fragment, do you expect Edge to process the entire template and return from the fragment output? Or do you expect Edge to only process the fragment contents? Also, it will be essential to answer:
|
Thanks for your response! Different frameworks handle this feature in various ways. For instance, in Laravel Blade, the entire template is rendered, and fragments are then extracted from the resulting HTML. However, this approach has clear performance drawbacks. To address your questions: Can fragments be nested? Can fragments be defined as partials or components? Can fragments live inside conditionals? Proposed example of usage:
|
I see. I think implementing the logic to only execute certain fragments will be challenging especially when they are the nested within conditionals or hidden behind components and partials. For example: If a fragment is written inside a component, we will have to execute that component (infact all the components) and then grab fragments from there. Now imagine, component calls themselves are wrapped in certain conditionals, then we will have to evaluate those conditionals too. I think, executing the entire template + extracting only the fragments should be the way to go. For those, who needs performance or are concerned with over data-fetching can use components and render them individually. Given that, this is something a nice to have feature and I may not look into it right away given the amount of other tasks I have at hand. |
Feature Request: Support for Template Fragments
Description
I’d like to propose adding support for template fragments in EdgeJS. When working with libraries like HTMX and DataStar, it’s often necessary to re-render small sections of a template in response to user interactions on the page.
Currently, this functionality can be achieved by breaking templates into components or partials. However, this approach tends to create an excessive number of small files, each containing minimal markup, which can make code harder to manage.
Proposed Feature
Introduce a mechanism to allow re-rendering specific subsections of a single template file without the need to split it into multiple components. This would streamline development while retaining the flexibility needed for partial updates.
Rationale
Adding support for template fragments would greatly improve developer experience when working with interactive libraries like HTMX and similar tools. For more context and examples, please refer to the following article: Template Fragments in HTMX.
The text was updated successfully, but these errors were encountered: