mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
6f7bf3f2d7
This commit adds a new `.InnerDeindent` method to the shortcode context, which is `.Inner` with any indendation removed. This is then used in the built-in `highlight` shortcode to prevent the extra whitespace getting hightlighted. Fixes #4717
1.9 KiB
1.9 KiB
title | linktitle | description | date | publishdate | lastmod | categories | keywords | draft | menu | weight | sections_weight | aliases | toc | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Shortcode Variables | Shortcode Variables | Shortcodes can access page variables and also have their own specific built-in variables. | 2017-03-12 | 2017-03-12 | 2017-03-12 |
|
|
false |
|
20 | 20 | false |
Shortcodes have access to parameters delimited in the shortcode declaration via .Get
, page- and site-level variables, and also the following shortcode-specific fields:
- .Name
- Shortcode name.
- .Ordinal
- Zero-based ordinal in relation to its parent. If the parent is the page itself, this ordinal will represent the position of this shortcode in the page content.
- .Page
- The owning ´Page`.
- .Parent
- provides access to the parent shortcode context in nested shortcodes. This can be very useful for inheritance of common shortcode parameters from the root.
- .Position
- Contains filename and position for the shortcode in a page. Note that this can be relatively expensive to calculate, and is meant for error reporting. See Error Handling in Shortcodes.
- .IsNamedParams
- boolean that returns
true
when the shortcode in question uses named rather than positional parameters - .Inner
- represents the content between the opening and closing shortcode tags when a closing shortcode is used
- .InnerDeindent {{< new-in "0.100.0" >}}
- Gets the
.Inner
with any indentation removed. This is what's used in the built-in{{</* highlight */>}}
shortcode.