Determine which shortcode notation was used

From within a shortcode template, is there any way to determine which notation was used to call the shortcode from markdown?

{{< shortcode >}}


{{% shortcode %}}

No it isn’t.

1 Like


{{ if strings.Contains $.Page.RawContent `{{%` }}Markdown{{ end }}
{{ if strings.Contains $.Page.RawContent `{{<` }}HTML{{ end }}

Possible Caveats:
The above checks the .RawContent of the entire parent Page, it is not limited to the shortcode input.
The above also works without the dollar sign, but on my end it was slower without it, might be an expensive check.

Thanks, but with multiple calls to the same shortcode within one document, I wanted to know how each one was called – no guarantee of consistent user behavior. I’ll find another way…

I’m gonna make some T shirts.

1 Like

This might not help too much, but may be you have an optional shortcode parameter “md” (which defaults to false), that you then check inside the shortcode.


{{< shortcode >}}


{{% shortcode md=true %}}

I’m assuming this is for some shortcodes that you have developed, and not from someone else’s themes.

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