Skip to content

Error when dealing with macro (parseAggregate: expected colon after dict key) #3036

Closed Answered by pdehaan
msm1227 asked this question in Q&A
Discussion options

You must be logged in to vote

Or if you want an alternate idea which uses a color map and tailwind colors:

---
title: 11ty-3036
injuries:
  - data: { impact: "Low" }
  - data: { impact: "Medium" }
  - data: { impact: "High" }
  - data: { impact: "Extreme" }
---

{% macro impactColor(injuryLevel) %}
  {%- set colorMap = {
    Low: "text-green-800",
    Medium: "text-yellow-300",
    High: "text-red-600"
  } -%}
  {%- set color = colorMap[injuryLevel] | default("text-purple-600") -%}
  <span class="injury-impact text-xs text-gray-500 dark:text-gray-400 {{ color }}">
    {{- injuryLevel -}}
  </span>
{% endmacro %}

{# {% from "impactColor.njk" import impactColor %} #}

{% for injury in injuries %}
  <p class="text-xs te…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@pdehaan
Comment options

pdehaan Sep 4, 2023
Collaborator

Answer selected by msm1227
@msm1227
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants