Skip to content

Commit

Permalink
tpl/tplimpl: Update details shortcode
Browse files Browse the repository at this point in the history
- Remove localization of default summary value
- Add title attribute
- Reformat to be consistent with other embedded templates
- Simplify and improve integration test
- Update documentation
  • Loading branch information
jmooring authored and bep committed Dec 13, 2024
1 parent f29f19a commit c9b23cf
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions content/en/content-management/shortcodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,32 +101,42 @@ Although you can call this shortcode using the `{{</* */>}}` notation, computati
{{% note %}}
To override Hugo's embedded `details` shortcode, copy the [source code] to a file with the same name in the layouts/shortcodes directory.

This may be useful if you are wanting access to more global HTML attributes.

[source code]: {{% eturl details %}}
{{% /note %}}

Use the `details` shortcode to generate a collapsible details HTML element. For example:
Use the `details` shortcode to create a `details` HTML element. For example:

```text
{{</* details summary="Custom Summary Text" */>}}
Showing custom `summary` text.
{{</* details summary="See the details" */>}}
This is a **bold** word.
{{</* /details */>}}
```

Additional examples can be found in the source code. The `details` shortcode can use the following named arguments:
Hugo renders this to:

```html
<details>
<summary>See the details</summary>
<p>This is a <strong>bold</strong> word.</p>
</details>
```

The details shortcode accepts these named arguments:

summary
: (`string`) Optional. Specifies the content of the child summary element. Default is "Details"
: (`string`) The content of the child `summary` element rendered from Markdown to HTML. Default is `Details`.

open
: (`bool`) Optional. Whether to initially display the contents of the details element. Default is `false`.
: (`bool`) Whether to initially display the content of the `details` element. Default is `false`.

class
: (`string`) The value of the element's `class` attribute.

name
: (`string`) Optional. The value of the element's name attribute.
: (`string`) The value of the element's `name` attribute.

class
: (`string`) Optional. The value of the element's class attribute.
title
: (`string`) The value of the element's `title` attribute.

### figure

Expand Down

0 comments on commit c9b23cf

Please sign in to comment.