gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
74.71k stars 7.45k forks source link

Provide Shortcode param Interface at Page Level #6579

Open HenrySkup opened 4 years ago

HenrySkup commented 4 years ago

So, we have .HasShortcode to tell us, at a page level, if a shortcode is used. It would be useful to be able to access the shortcodes' params at this point, too, to allow for some finer grain control .

bep commented 4 years ago

I don't see how. Params are per shortcode used, and you can use the same shortcode multiple times per content file.

HenrySkup commented 4 years ago

true, but if the content has been parsed to find the shortcodes, i would assume that it could have access at that point to each shortcode's param values? My use case is:

I wand to have multiple canvases one one page (using a {{< canvas >}} shortcode that references the JS script that codes the canvas). All canvases react and style the same way, but each may use different dependencies.

Currently there is no way to indicate at a page level these different dependencies. Of course I could have differently named shortcodes to indicate this -- this wouldn't be very DRY.

bep commented 4 years ago

true, but if the content has been parsed to find the shortcodes, i would assume that it could have access at that point to each shortcode's param values?

That's true, I guess. But I need to think some about this.