Conditional overloading of an embedded shortcode post 0.146.0?

hey gang!

Trying to wrap my head around the changes in 0.146.x

I use a spinoff of jpanther’s awesome congo theme.
One of the things he does in this theme is to overload the figure shortcode with some custom logic, conditionally, falling back to the inbuilt shortcode via {{ template "_internal/shortcodes/figure.html" . }}
which obviously isn’t the thing to do anymore. :slight_smile:

However, I’m a little confused as to the proper way forward here.

A downstream fork of congo; blowfish, has an open PR to address the problems experienced post 0.146.x. However I’m not convinced the logic there actually works for the shortcode’s fallthrough case..
(I suspect the site demo doesn’t exercise the fallback path and so it’s a bug in hiding)
… not because I eyeballed it and thought

That doesn’t look right…

…but because it doesn’t work for me :slight_smile:

Error: error building site: render: failed to render pages: render of  "wplsc/content/snippits/wplshortcodes/shortcodes/spoiler.md" failed: "wplsc/layouts/_default/single.html:131:11": execute of template failed:
 template: single.html:131:11: executing "main" at <.Content>: error calling Content: 
   failed to render shortcode: "wplsc/content/snippits/wplshortcodes/shortcodes/spoiler.md:117:1":
     failed to render shortcode "columns": "wplsc/content/snippits/wplshortcodes/shortcodes/spoiler.md:1:1": 
       failed to render shortcode "spoiler": "wplsc/content/snippits/wplshortcodes/shortcodes/spoiler.md:1:1": 
         failed to render shortcode "figure": failed to process shortcode: "wplsc/themes/congo/layouts/shortcodes/figure.html:2:5": 
           execute of template failed: template: _shortcodes/figure.html:2:5: executing "_shortcodes/figure.html" at <partial "shortcodes/figure.html" .>: 
            error calling partial: partial "shortcodes/figure.html" not found

(( BTW: I like the much more explicit failure pathing… nicely done. Much more grokable as to what’s breaking where ))

I’ve seen a few bits of guidance on this, and from what I’ve gathered the “right” way forward is, essentially:

DON’T DO THAT ANYMORE :slight_smile:

Instead, if you wish to conditionally utilize them, Create a wrapper which encapsulates your conditional logic and them optionally invoke the internal shortcode
IE:
mytheme/layouts/shortcodes/figure-wrapper.html
vs
mytheme/layouts/shortcodes/figure.html

so my read on this is that overloading the embedded shortcodes is now (officially) an antipattern to be avoided.

Is that accurate? or have I misunderstood (also entirely possible, hence why I’m posting here) :slight_smile:

Hope y’all are having a great day/night!

:heart::wolf:W

This construct is unexpected and undocumented:

It was and will continue to be an antipattern.

The wrapper needs a new name.

1 Like

That’s what I figured the answer is/was; but wanted to be explicit as it’s going to cause some disruption to consumers of the theme(s)

Is the guidance you provided wrt wrappers documented someplace explicitly that I can point to alongside my PR to congo, to help illustrate the need for the breaking change?

(Regardless of the fact that it was a BadIdea™️ from the get-go; people don’t like change…
…and I can’t really fault them for that… especially given the last few years we’ve ALL endured… )

y’all have done a TREMENDOUS amount of work in 0.146.x to pivot from lessons learned …

even though it’s a pain in my backside, I really truly do appreciate the dedication to clean/better/right :slight_smile:

as always, Joe I sincerely appreciate your contributions, guidance, and patient pedanticism :wink:
The hugo community is truly fortunate to receive the gift of your time.

Thank you once again.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.