We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Conditionals, Variables, Frontmatter

Nico del Castillo February 12, 2015 by Nico del Castillo

I think I'm missing something in this. Can I run a conditional with variables from my frontmatter? Trying to output something different according to a match, but it only ever runs the "else" part.

In the .md file:

---
stuff:
  -
    type: red
    output: condition1
  -
    type: blue
    output: condition2
  -
    type: green
    output: condition3
  -
    type: potato
    output: condition4
---

And then in the template file:

<ul>
{{ stuff }}
  <li>{{ if type == "potato" }} Highlighting {{ output }} because it's special {{ else }} A simple {{ output }} {{ endif }}</li>
{{ /stuff }}
</ul>
Answered by Alex Armstrong!
>>>>>>> Answered <<<<<<<
6 Replies
4 Followers