Expose the signed-in user and other request context to a view Engine

Aperta
#787 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à
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
38/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
backend

Direzione di ricerca

Start by reading Template and the Engine extension point, then inspect how request context is made available to views. The issue identifies signed-in user access as a concrete gap; the broader request, authorization, config, translation, and clock APIs need a design decision. Done means agreeing on the supported context API and exposing the selected data to engines.

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

Descrizione

I built an external Blade engine on top of laravel::view::Engine (https://github.com/RicardoAugustoTulio/laravel-rust-blade) to ease migrating Laravel PHP apps. The extension point worked without framework changes, including a multi-dot extension (engine("blade.php", ..)) next to MiniJinja .html views. A few things an Engine can't reach, so the crate works around them:

  1. Named routes. Already reported in #784. I'd use the same route_named lookup.
  2. The signed-in user. @auth and @guest have to read the session value under the literal key "_auth.web.id". USER_ID_KEY (crates/http/src/session/mod.rs) isn't re-exported by laravel, so the engine depends on that spelling. Either pub use the constant from laravel::session, or add Template::user_id() -> Option<...>.
  3. Request, authorization, config, translations, clock. Nothing on Template gives an engine the request (request()->is(..)), @can checks, config values or translated strings. The crate fails these at compile time with a message, and lets the application register its own function. If a small read-only handle (for example the request's path and query, or a way to run a policy check) is welcome on Template, I can propose the shape in a PR. If not, the current workaround is fine.

The engine's other framework notes are in https://github.com/RicardoAugustoTulio/laravel-rust-blade/blob/master/docs/FRAMEWORK.md.

Seen on 0.x. Happy to send a PR for 2 if the approach is welcome.

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.