Checking if param is equal template parameter inside range

Thanks for stopping by :smiley:


So, I’m building a website that has a set of layout and style presets defined by the user in each page’s front matter. The way I control each preset is through an HTML class, following the BEM methodology. So, for example, the hero section with a “Hipster” style and a header is defined by

<section class="hero hero_Hipster hero_header">

In order to assign these classes relative to the .md file, I use a goLogic.html file with a “bem” function defined, using the snippet {{ template "bem" (dict "context" . "class" "hero" "vibe" true "layout" "header")}}. Inside the “bem” function I need to, if “layout” is set, loop through the pages .Params and find the “class” array and display the “layout” value if it’s set to true. I’ve tried many methods, the latest using a range where function, to no avail. Here’s how it looks rn:

  {{- $class := .class -}}
  {{- $layout := .layout -}}
  {{- $index := .context.Params -}}

  {{- if .layout }} {{ .class }}_
    {{- range where $index (print $class) true -}}
      {{$layout}}
    {{- end -}}
  {{- end -}}

The problem so far has been that .context.Params renders each sub array as map[] instead of (name of the parameter)[]. Anyone with better knowledge on ranges that could help me out? :slight_smile:

Reference - part of the .md file:

SEO:
  description: >-
    Nós entendemos do seu estilo! Venha fazer uma visita e vamos te deixar mais linda do que nunca!
  favicon: /images/logoDark.png
  image: /images/logoLight.png
  title: O melhor salão do Lourdes - Salão da Viki
hero:
  logo: true
  imageboolean: true
  header: true

(in this example, I want to cycle through index.md and return the template variable layout if .Params.hero.header is true)