Skip to contents

Safely extracts a nested element from a brand object using the provided key path. Returns NULL if the element doesn't exist.

Usage

brand_pluck(brand, ...)

Arguments

brand

A brand object created by read_brand_yml() or as_brand_yml().

...

One or more character strings or symbols representing the path to the nested element to extract.

Value

The value of the nested element if it exists, NULL otherwise.

See also

Other brand.yml helpers: brand_color_pluck(), brand_has()

Examples

brand <- as_brand_yml(list(
  meta = list(name = "Example Brand"),
  color = list(primary = "#FF5733")
))

# Extract the primary color
brand_pluck(brand, "color", "primary") # "#FF5733"
#> [1] "#FF5733"

# Try to extract a non-existent element
brand_pluck(brand, "color", "secondary") # NULL
#> NULL