Skip to contents

Retrieve a mighty code component.

  • get_component(): Returns an object of class mighty_component.

  • get_rendered_component(): Returns an object of class mighty_component_rendered.

When rendering a component the required list of parameters depends on the individual component. Check the documentation of the local component for details.

Usage

get_component(component, repos = NULL)

get_rendered_component(component, params = list(), repos = NULL)

Arguments

component

character component name, or path to a component file (.R or .mustache) when repos is NULL.

repos

prioritized character vector of locations to look for component in. See details.

params

named list of input parameters. Passed along to mighty_component$render().

Details

Processes different component types based on file extension:

  • .R: Extracts and renders custom functions.

  • .mustache: Creates components from the template files.

The repos parameter accepts a character vector of locations to search, in priority order. Each element is a repo spec passed to mighty_repo(): a local directory path, or a GitHub source prefixed with github:: in owner/repo, owner/repo/subdir, or owner/repo@ref format. The first match is returned.

When repos is NULL, component is a path to a component file. Otherwise component is a component name, with or without extension, looked up in repos.

Examples

path <- system.file("examples", "ady.mustache", package = "mighty.component")
get_component(path)
#> → Found "ady.mustache" in "local::/home/runner/work/_temp/Library/mighty.component/examples"
#> <mighty_component/R6>
#> ady.mustache: Analysis relative day
#> Type: column
#> Parameters:
#> • domain: `character` Name of new domain being created
#> • variable: `character` Name of new variable to create
#> • date: `character` Name of date variable to use
#> Depends:
#> • {{{domain}}}.{{{date}}}
#> • {{{domain}}}.TRTSDT
#> Outputs:
#> • {{{variable}}}