-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.HasAnyShortcode : return TRUE if a page uses at least one shortcode #7996
Comments
I agree about the "we need this", but I'm not sure we need another method. I think it fits with what we do in other areas of the template funcs that we have a vararg argument. So if we make /cc @moorereason |
Make HasShortcode parameter variadic to allow for the testing of any shortcodes instead of only named shortcodes. Fixes gohugoio#7996
OK, looking at the use case, I think I misunderstood the use case, but know I think. I do, and I take back what I said about "retrofitting" the I think we need a method |
First, as is usually the case, when I program late at night, I usually missing something. In this case, I didn't catch the fact that this PR is proposing two changes:
My PR retrofitting @bep, |
Let us create |
What about the existing PR and the test for any unnamed shortcodes case? |
FYI, what I finally did, as I had the case for both partials and shortcodes, is setting a boolean to true in the partial/shortcode using .Scratch.Set, and checking for that boolean to include or not my javascripts. These are all in the footer, after the shortcodes. I have not tested if this work for CSS in the |
Similar to
.HasShortcode
, but without having the need to specify a shortcode name as parameter..HasAnyShortcode
would Return TRUE if at least one shortcode is used in the page else Return FALSEUse case: CSS/JS libraries containing the code needed for a set of shortcodes. This would avoid to have to check for existence of all shortcodes one by one.
Alternatives could be:
.HasShortcode
, like.HasShortcode Any
.HasShortcode
with an array to test if one of the shortcodes in the array is usedThe text was updated successfully, but these errors were encountered: