Skip to content
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

[Feature Request] Fragment/Partial Rendering Support #641

Open
TareqK opened this issue Jan 10, 2023 · 1 comment
Open

[Feature Request] Fragment/Partial Rendering Support #641

TareqK opened this issue Jan 10, 2023 · 1 comment

Comments

@TareqK
Copy link

TareqK commented Jan 10, 2023

So The concept here is to allow rendering part of a template, instead of the whole template, by defining a fragments system. This isnt the same as including a template in a template, and the main value is related to the use of pebble in SSR applications. Effectively, instead of passing the template you want to render, like my-template.peb, you would pass my-template.peb#fragment-name, which would only render the relevant section of a template, eg, lets say i have my-template.peb which looks like this

{ % fragment fragment-1 % }
 Hi-There
{ %endfragment%}

{ % fragment fragment-2 % }
Its-a-me
{ %endfragment%}

if I chose to render my-template.peb#fragment-1, i would get

Hi-There

if i choose to render my-template.peb, i would get

Hi There
Its-a-me

so on and so forth

further rationale on the value of this can be found here https://htmx.org/essays/template-fragments/

More than happy to contribute this, if there is room for it. It introduces no breaking changes.

@rdehuyss
Copy link

+1
Also in favor of this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants