Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use shortcode within definition of shortcode

How can I reuse a shortcode in Hugo within another shortcode?

I only found a way to nest shortcodes within markdown but what I want to do is to reuse a shortcode within the definition of another shortcode.

like image 434
user2033412 Avatar asked Mar 28 '19 15:03

user2033412


1 Answers

No not in the definition, but you can use nested Shortcodes.

The nested approach is the official one (as discussed here):

Nested Shortcodes

You can call shortcodes within other shortcodes by creating your own templates that leverage the .Parent variable.
.Parent allows you to check the context in which the shortcode is being called.
See Shortcode templates.

See an illustration here: this is a workaround, and not one shortcode using another.

like image 134
VonC Avatar answered Nov 06 '22 17:11

VonC