Attributes without values in shortcodes

I have a shortcode that takes about 10 attributes for configuration.

However some of them are booleans, such as global="true" or editable="true". I only want to find out that these attributes are specified (and assume the value is true).

For example, I’m trying to get:

{{<cliparam id="foo" editable="true" global="true">}}...{{</cliparam>}}

shortened to:

{{<cliparam id="foo" editable global>}}...{{</cliparam>}}

However I’m getting errors like:

got positional parameter 'editable'. Cannot mix named and positional parameters

I’m curious if it’s possible to do at all.

An interim/workaround solution I can think of is using it with empty values like this (which I think looks ugly):

{{<cliparam id="foo" editable="" global="">}}...{{</cliparam>}}

The error message is clear: You have to pick one or the other.

1 Like