Feature matrix shortcode

I created this shortcode in the middle of writing a blog post about Hugo, trying to illustrate the variations of file types in play.

I might post a link to that blog post when ready, but thought the shortcode could give some ideas for others to use.

So:

Shortcode:

<div class="list-checkboxes">
{{ $all := (slice "JSON" "YAML" "TOML" "Blackfriday" "Asciidoctor" "reStructuredText" "HTML" "Ace" "Go" "Amber" )}}
{{ range $all }}
    {{ $current := . }}
    {{ if in $.Params $current }}<input type="checkbox" checked="" disabled="" class="task-list-item">{{else}}<input type="checkbox" disabled="" class="task-list-item">{{end}}&nbsp;{{ $current }}
{{ end }}
</div>

In content file:

| File Type | Variants |
| ---|---|
|Content|{{<hf JSON YAML TOML Blackfriday Asciidoctor reStructuredText HTML >}}
|Config|{{<hf JSON YAML TOML >}}
|Data|{{<hf JSON YAML TOML >}}
|Language|{{<hf JSON YAML >}}
|Layout|{{<hf Go Ace Amber HTML >}}
|Shortcode|{{<hf Go Ace Amber HTML >}}

Result:

A fairly compact and simple way to show a feature matrix.

1 Like

Thx for sharing this technique. It gives a shine of light in the darkness.