Whitespace chomping inside shortcodes
tags: chomp whitespace shortcode
Description/Summary
Use of whitespace chomping braces in shortcodes.Content
Shortcode definition (inner-chomp
)
<div>{{- .Inner -}}</div>
Shortcode use
{{< inner-chomp >}}
Hello
{{< /inner-chomp >}}
Expected HTML
<div>Hello</div>
Observed HTML
View the source of this page and search for “Hello”.
<div>
Hello
</div>
Workaround
The workaround is to put the opening/closing shortcode identifiers on the same line.
{{< inner-chomp >}}Workaround{{< /inner-chomp >}}
View the source of this page and search for “Workaround”.
Page (Debug)
Page Variable | Value | |
---|---|---|
Name | "Whitespace chomping inside shortcodes" | |
Title | "Whitespace chomping inside shortcodes" | |
ResourceType | "page" | |
Kind | "page" | |
Section | "bugs" | |
Draft | false | |
Type | "bugs" | |
Layout | "" | |
Permalink | "https://hugo-sandbox.netlify.com/bugs/whitespace-chomping-in-shortcodes/" | |
RelPermalink | "/bugs/whitespace-chomping-in-shortcodes/" | |
Data |
| |
NextPage | Notes on HEP course | |
PrevPage | Image captions with Markdown | |
NextInSection | None | |
PrevInSection | date and publishdate |
Page Params (Debug)
maps.Params{"author":[]string{"Kaushal Modi"}, "creator":"Emacs 27.0.50 (Org mode 9.1.11 + ox-hugo)", "date":time.Date(2018, time.April, 23, 8, 46, 0, 0, time.Location("")), "description":"Use of whitespace chomping braces in shortcodes.", "draft":false, "iscjklanguage":false, "lastmod":time.Date(2018, time.April, 23, 8, 54, 6, 0, time.Location("")), "publishdate":time.Date(2018, time.April, 23, 8, 46, 0, 0, time.Location("")), "tags":[]string{"chomp", "whitespace", "shortcode"}, "title":"Whitespace chomping inside shortcodes"} (type:maps.Params) |
File Object (Debug)
FileInfo Variable | Value |
---|---|
UniqueID | "9f1626a9785354434092e0dc66f3886f" |
BaseFileName | "whitespace-chomping-in-shortcodes" |
TranslationBaseName | "whitespace-chomping-in-shortcodes" |
Lang | "en" |
Section | "bugs" |
LogicalName | "whitespace-chomping-in-shortcodes.md" |
Dir | "bugs/" |
Ext | "md" |
Path | "bugs/whitespace-chomping-in-shortcodes.md" |