Skip to content

[Feature Request] Fragment/Partial Rendering Support #641

@TareqK

Description

@TareqK

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions