mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-22 21:42:50 +02:00
Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
---
|
||||
title: InnerDeindent
|
||||
description: Returns the content between opening and closing shortcode tags, with indentation removed, applicable when the shortcode call includes a closing tag.
|
||||
description: Returns the content between opening and closing shortcode tags, with indentation removed, applicable when the shortcode call includes a closing tag.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/shortcode/Inner
|
||||
returnType: template.HTML
|
||||
signatures: [SHORTCODE.InnerDeindent]
|
||||
params:
|
||||
functions_and_methods:
|
||||
returnType: template.HTML
|
||||
signatures: [SHORTCODE.InnerDeindent]
|
||||
---
|
||||
|
||||
Similar to the [`Inner`] method, `InnerDeindent` returns the content between opening and closing shortcode tags. However, with `InnerDeindent`, indentation before the content is removed.
|
||||
@@ -16,7 +15,7 @@ This allows us to effectively bypass the rules governing [indentation] as provid
|
||||
|
||||
Consider this Markdown, an unordered list with a small gallery of thumbnail images within each list item:
|
||||
|
||||
{{< code file=content/about.md lang=md >}}
|
||||
```text {file="content/about.md"}
|
||||
- Gallery one
|
||||
|
||||
{{</* gallery */>}}
|
||||
@@ -30,17 +29,17 @@ Consider this Markdown, an unordered list with a small gallery of thumbnail imag
|
||||

|
||||

|
||||
{{</* /gallery */>}}
|
||||
{{< /code >}}
|
||||
```
|
||||
|
||||
In the example above, notice that the content between the opening and closing shortcode tags is indented by four spaces. Per the CommonMark specification, this is treated as an indented code block.
|
||||
|
||||
With this shortcode, calling `Inner` instead of `InnerDeindent`:
|
||||
|
||||
{{< code file=layouts/shortcodes/gallery.html >}}
|
||||
```go-html-template {file="layouts/shortcodes/gallery.html"}
|
||||
<div class="gallery">
|
||||
{{ .Inner | strings.TrimSpace | .Page.RenderString }}
|
||||
</div>
|
||||
{{< /code >}}
|
||||
```
|
||||
|
||||
Hugo renders the Markdown to:
|
||||
|
||||
@@ -67,11 +66,11 @@ Hugo renders the Markdown to:
|
||||
|
||||
Although technically correct per the CommonMark specification, this is not what we want. If we remove the indentation using the `InnerDeindent` method:
|
||||
|
||||
{{< code file=layouts/shortcodes/gallery.html >}}
|
||||
```go-html-template {file="layouts/shortcodes/gallery.html"}
|
||||
<div class="gallery">
|
||||
{{ .InnerDeindent | strings.TrimSpace | .Page.RenderString }}
|
||||
</div>
|
||||
{{< /code >}}
|
||||
```
|
||||
|
||||
Hugo renders the Markdown to:
|
||||
|
||||
|
Reference in New Issue
Block a user