Render several fragments of a view at once (fragments, fragmentsIf)

Aperta
#862 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
backend

Direzione di ricerca

Start by reading the View::fragment and Template::block() APIs and how the engine consumes them; the issue names no source files or tests. Trace how fragment selection reaches an engine, then determine how ordered multiple fragments should be passed through and rendered. Done means fragments and fragments_if support multiple names while preserving single-fragment behavior and rendering in order.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Laravel's fragments(['a', 'b']) and fragmentsIf(...) render several fragments of one view in order, which htmx-style responses use to update more than one region at once. Laravel for Rust 0.2 has View::fragment and fragment_if for one fragment only.

use laravel::view::view;

let page = view("two", ()).fragment("a").fragment("b");
// The second call replaces the first: only "b" renders.

let page = view("two", ()).fragments(["a", "b"]);
// error[E0599]: no method named `fragments` found for struct `View`

View::fragment stores self.block = Some(..), and an Engine reads it through Template::block() -> Option<&str>, so a third-party engine can't receive more than one name either.

A possible shape: View::fragments(names) and fragments_if(condition, names), and Template::blocks() -> &[String] (keeping block() for a single fragment), with engines concatenating the fragments in the order given, as Laravel does.

Context: this came up while porting Blade to Laravel for Rust as a view engine (oxblade); it supports multiple fragments in its own API but can't receive them from View.

Lingua principale
Rust
Stelle
847
Fork
174
Merge medio
5h 40m
PR unite (30g)
167

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di laravel/rust-framework

Tutte le issue di laravel/rust-framework

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.