Lava Filters - PropertyToKeyValue

Category:Other

Description:Takes a property and returns it as a key/value pair. This is helpful for iterating over a list of properties.
Input: "CurrentPerson": { "Attributes": [ { "FavoriteMovie": "Star Wars" }, { "FavoriteStarWarsEpisode": "Episode VI" }, { "FavoriteStarWarsCharacter": "Boba Fett" } ] }
Lava:
    {% for attribute in Attributes %} {% assign attributeParts = attribute | PropertyToKeyValue %}
  • {{ attributeParts.Key | Humanize | Capitalize }}: {{ attributeParts.Value }}
  • {% endfor %}
Output:
  • Favorite Movie: Star Wars
  • Favorite Star Wars Episode: Episode VI
  • Favorite Star Wars Character: Boba Fett