Learn R Programming

brand.yml (version 0.1.0)

with_brand_yml_path: Temporarily set the BRAND_YML_PATH environment variable

Description

This function sets the BRAND_YML_PATH environment variable to the specified path for the duration of the local environment. This ensures that, for the scope of the local environment, any calls to functions that automatically discover a _brand.yml file will use the path specified.

Usage

with_brand_yml_path(path, code)

local_brand_yml_path(path, .local_envir = parent.frame())

Value

[any]
The results of the evaluation of the code

argument.

Arguments

path

The path to a brand.yml file.

code

[any]
Code to execute in the temporary environment

.local_envir

[environment]
The environment to use for scoping.

Functions

  • with_brand_yml_path(): Run code in a temporary environment with the BRAND_YML_PATH environment variable set to path.

  • local_brand_yml_path(): Set the BRAND_YML_PATH environment variable for the scope of the local environment (e.g. within the current function).

See Also

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

Examples

Run this code
# Create a temporary brand.yml file in a tempdir for this example
tmpdir <- withr::local_tempdir("brand")
path_brand <- file.path(tmpdir, "my-brand.yml")
yaml::write_yaml(
  list(color = list(primary = "#abc123")),
  path_brand
)

with_brand_yml_path(path_brand, {
  brand <- read_brand_yml()
  brand$color$primary
})

Run the code above in your browser using DataLab