From 55d5a2787167a5b50f2625d2eb1e86d1add79486 Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Tue, 19 Mar 2024 08:03:42 -0700 Subject: [PATCH] Update partial function example --- content/en/functions/partials/Include.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/content/en/functions/partials/Include.md b/content/en/functions/partials/Include.md index 191e083b9..6da7e33bc 100644 --- a/content/en/functions/partials/Include.md +++ b/content/en/functions/partials/Include.md @@ -48,21 +48,24 @@ The "footer" partial renders the site footer. In this contrived example, the foo {{ partial "breadcrumbs.html" }} ``` -You can pass anything in context: a page, a page collection, a scalar value, a slice, or a map. For example: +You can pass anything in context: a page, a page collection, a scalar value, a slice, or a map. In this example we pass the current page and three scalar values: ```go-html-template -{{ $student := dict +{{ $ctx := dict + "page" . "name" "John Doe" "major" "Finance" "gpa" 4.0 }} -{{ partial "render-student-info.html" $student }} +{{ partial "render-student-info.html" $ctx }} ``` Then, within the partial template: ```go-html-template -

{{ .name }} is majoring in {{ .major }}. Their grade point average is {{ .gpa }}.

+

{{ .name }} is majoring in {{ .major }}.

+

Their grade point average is {{ .gpa }}.

+

See details.

``` To return a value from a partial template, it must contain only one `return` statement, placed at the end of the template: