Docs about stopping the Cascade

Offen
#1,576 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
35/100
Issue-Typ
Dokumentation
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
php
Bereich
documentation

Rechercherichtung

Read the Data Inheritance page and the linked Partial tag documentation about passing data. Check how the issue’s view:class example fits the Cascade behavior, then document the recommended approach if confirmed. Done means the docs explain how to prevent a nested partial from inheriting a parent’s class value.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Often partials use a param called class and are nested. In that case, I don't want to use the parent class data in a nested partial that doesn't receive class itself:

{{# The parent partial receives a class. #}}
{{ partial:parent class="some-class" }}
{{#
    @name Parent
    @param class Custom CSS classes.
#}}

{{# No class passed to the child. #}}
<div :$class>
    {{ partial:child }}
</div>
{{#
    @name Child
    @param class Custom CSS classes.
#}}

{{# Since class is null, the Cascade would look upwards until it finds class data. #}}
<div :$class>
    I am a child.
</div>

My solution here was to use view:class. The nested partial doesn't receive the parent's class data anymore. I don't know if this is the intended use case (besides that).

I would either add this as a "best practice" (like in the linked docs article) to the Data Inheritance docs page or another solution that might be better.

Vorherrschende Sprache
PHP
Sterne
133
Forks
405
Ø Merge
1 T. 16 Std.
Gemergte PRs (30 T.)
13

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus statamic/docs

Alle Issues in statamic/docs

Ähnliche Issues

Weitere Issues zu PHP

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.