diff --git a/filters/map.md b/filters/map.md index 769b976a..37b7b9aa 100644 --- a/filters/map.md +++ b/filters/map.md @@ -2,10 +2,24 @@ title: map --- -Collects an array of properties from a hash. +Creates an array of values by extracting the values of a named property from another object. -| Code | Output | -|:-------------------------------------------------------|:-------------------| -| {% raw %}`{{ product | map: 'tag' }}`{% endraw %} | `["sale", "mens", "womens", "awesome"]` | +In this example, assume the object `site.pages` contains all the metadata for a website. Using `assign` with the `map` filter creates a variable that contains only the values of the `category` properties of everything in the `site.pages` object. -In the sample above, assume that `product` resolves to: `[{ tags: "sale"}, { tags: "mens"}, { tags: "womens"}, { tags: "awesome"}]`. +```liquid +{% raw %} +{% assign all_categories = site.pages | map: "category" %} + +{% for item in all_categories %} +{{ item }} +{% endfor %} +{% endraw %} +``` + +```text +business +celebrities +lifestyle +sports +technology +```