Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Rendering parity: empty containers and undefined render as empty, `-}}` trims only part of the whitespace

Aperta
#290 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
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
backend

Direzione di ricerca

Start with src/internal_value.cpp for stringification, src/statements.cpp for the renderer stream path, and src/template_parser.h for StripBlockRight and its call sites. Reproduce the four templates from the issue, then trace each affected path. Done means empty containers and undefined elements use the expected Python repr forms and -}} removes the full following whitespace run.

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

Descrizione

Three rendering differences from Jinja2 on the same templates. Boolean spelling is tracked separately in #266 and is not part of this report.

Affected: master 79af49f (releases 1.1.0, 1.2.1 and 1.3.2).

Reproduction

template Jinja2 Jinja2Cpp
{{empty}} where empty is an empty list [] empty output
{{[q]}} where q is undefined [Undefined] empty output
{{ {} }} {} empty output
{{9999-}} followed by \n\t 9999 9999\t

The first three come from value stringification. The fourth comes from whitespace control: after -}} the engine trims only part of the trailing whitespace run. Top-level output is unaffected, so {{ q }} alone agrees between the engines.

Expected: Python reprs for empty containers and undefined elements, and a full right trim after -}}.

Actual: empty output for the containers and a partial trim after -}}.

Root cause

Value stringification in src/internal_value.cpp and the renderer stream path in src/statements.cpp do not use Python repr forms for sequences, maps, or undefined elements. Whitespace control in src/template_parser.h (StripBlockRight and its call sites) does not consume the whole whitespace run after -}}.

Lingua principale
C++
Stelle
602
Fork
115
Merge medio
2h 34m
PR unite (30g)
317

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 jinja2cpp/Jinja2Cpp

Tutte le issue di jinja2cpp/Jinja2Cpp

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.