Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'

This commit is contained in:
Bjørn Erik Pedersen
2025-04-10 13:04:51 +02:00
987 changed files with 12379 additions and 14083 deletions

View File

@@ -3,24 +3,16 @@ title: InSection
description: Reports whether the given page is in the given section.
categories: []
keywords: []
action:
related:
- methods/page/Ancestors
- methods/page/CurrentSection
- methods/page/FirstSection
- methods/page/IsAncestor
- methods/page/IsDescendant
- methods/page/Parent
- methods/page/Sections
returnType: bool
signatures: [PAGE.InSection SECTION]
toc: true
params:
functions_and_methods:
returnType: bool
signatures: [PAGE.InSection SECTION]
---
The `InSection` method on a `Page` object reports whether the given page is in the given section. Note that the method returns `true` when comparing a page to a sibling.
{{% glossary-term section %}}
The `InSection` method on a `Page` object reports whether the given page is in the given section. Note that the method returns `true` when comparing a page to a sibling.
With this content structure:
```text
@@ -83,9 +75,8 @@ Inside of the `with` block, the [context](g) (the dot) is the section `Page` obj
The result would be wrong when rendering the "auction-1" page because we are comparing the section page to itself.
{{% note %}}
Use the `$` to get the context passed into the template.
{{% /note %}}
> [!note]
> Use the `$` to get the context passed into the template.
```go-html-template
{{ with .Site.GetPage "/auctions" }}
@@ -93,9 +84,8 @@ Use the `$` to get the context passed into the template.
{{ end }}
```
{{% note %}}
Gaining a thorough understanding of context is critical for anyone writing template code.
{{% /note %}}
> [!note]
> Gaining a thorough understanding of context is critical for anyone writing template code.
[`with`]: /functions/go-template/with/
[`else`]: /functions/go-template/else/
[`with`]: /functions/go-template/with/