Including Subviews
Including Subviews
Section titled “Including Subviews”@include("partials.nav")Pass a second argument to merge data into the child context (parent data is copied first):
@include("partials.alert", {"type": "success", "message": message})Conditional includes
Section titled “Conditional includes”| Directive | Behavior |
|---|---|
@includeIf("view") |
Include only when the view exists on disk |
@includeWhen(cond, "view") |
Include when cond is truthy |
@includeUnless(cond, "view") |
Include when cond is falsy |
Optional data dicts work the same way as @include (second arg for
@includeIf, third for when/unless).
@includeIf("partials.banner")@includeWhen(user, "partials.account", {"user": user})@includeUnless(preview, "partials.footer")Rendering collections with @each
Section titled “Rendering collections with @each”@each("partials.job", jobs, "job")@each("partials.job", jobs, "job", "partials.no-jobs")Prism renders the first view once per item (binding the item under the given variable name). When the collection is empty and a fourth view is provided, that empty view is rendered instead.